From bdc11a7b83ee181fa0aa9528d4e1eeeff7b0e0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20W=C3=BCnsche?= Date: Tue, 5 Sep 2023 08:13:31 +0200 Subject: [PATCH] Use unique quadrature grid in nfft in case of Gauss-Legendre quadrature --- SO3Fun/@SO3FunHarmonic/adjoint.m | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/SO3Fun/@SO3FunHarmonic/adjoint.m b/SO3Fun/@SO3FunHarmonic/adjoint.m index 3027a608a..1a92bb711 100644 --- a/SO3Fun/@SO3FunHarmonic/adjoint.m +++ b/SO3Fun/@SO3FunHarmonic/adjoint.m @@ -71,20 +71,24 @@ rot = orientation(rot,SRight,SLeft); end -if isa(rot,'quadratureSO3Grid') +if isa(rot,'quadratureSO3Grid') N = rot.bandwidth; - values = values(rot.iuniqueGrid); - W = rot.weights; + if strcmp(rot.scheme,'ClenshawCurtis') + values = values(rot.iuniqueGrid); + W = rot.weights; + else % use unique grid in NFFT in case of Gauss-Legendre quadrature + if SRight.multiplicityPerpZ*SLeft.multiplicityPerpZ == 1 + GC = 1; + else + GC = groupcounts(rot.iuniqueGrid(:)); + end + W = rot.weights(rot.ifullGrid).*GC; + end else N = get_option(varargin,'bandwidth', getMTEXpref('maxSO3Bandwidth')); W = get_option(varargin,'weights',1); end -% use full grid in case of Gauss-Legendre Quadrature grid -if isa(rot,'quadratureSO3Grid') && ~strcmp(rot.scheme,'ClenshawCurtis') - rot = rot.fullGrid; -end - % check for Inf-values (quadrature fails) if any(isinf(values)) error('There are poles at some quadrature nodes.') @@ -173,8 +177,8 @@ sym = [min(SRight.multiplicityPerpZ,2),SRight.multiplicityZ,... min(SLeft.multiplicityPerpZ,2),SLeft.multiplicityZ]; % if random samples the symmetry properties do not fit -if ~isa(rot,'quadratureSO3Grid') - sym([1,3])=1; +if ~isa(rot,'quadratureSO3Grid') || strcmp(rot.scheme,'GaussLegendre') + sym([1,3]) = 1; end % use adjoint representation based coefficient transform fhat = adjoint_representationbased_coefficient_transform(N,ghat,flags,sym);