Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Jean-Eric Campagne
LagSHT
Commits
42092f70
Commit
42092f70
authored
Nov 23, 2015
by
Jean-Eric Campagne
Browse files
(JEC) 23/11/15 avoid recomputation of the jlnp factors as much as possible
parent
055b5a58
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
393386 additions
and
94 deletions
+393386
-94
Makefile
Makefile
+1
-0
data/jlnp-L12-N64-P512-PP512.txt
data/jlnp-L12-N64-P512-PP512.txt
+393216
-0
setup.csh
setup.csh
+1
-0
setup.sh
setup.sh
+1
-0
src/lagsht_testsuite.cc
src/lagsht_testsuite.cc
+43
-6
src/laguerre2bessel.cc
src/laguerre2bessel.cc
+89
-62
src/laguerre2bessel.h
src/laguerre2bessel.h
+32
-23
src/laguerreBuilder.h
src/laguerreBuilder.h
+3
-3
No files found.
Makefile
View file @
42092f70
...
@@ -52,6 +52,7 @@ all : confcheck makedir lib lagsht_testsuite
...
@@ -52,6 +52,7 @@ all : confcheck makedir lib lagsht_testsuite
install
:
install
:
mkdir
-p
$(INCL)
mkdir
-p
$(INCL)
cp
$(SRC)
/
*
.h
$(INCL)
cp
$(SRC)
/
*
.h
$(INCL)
.PHONY
:
check
.PHONY
:
check
...
...
data/jlnp-L12-N64-P512-PP512.txt
0 → 100644
View file @
42092f70
This diff is collapsed.
Click to expand it.
setup.csh
0 → 100755
View file @
42092f70
setenv LAGSHTROOTDIR /Users/campagne/Travail/Software/Laguerre/LagSHT
setup.sh
0 → 100755
View file @
42092f70
LAGSHTROOTDIR
=
/Users/campagne/Travail/Software/Laguerre/LagSHT
;
export
LAGSHTROOTDIR
;
src/lagsht_testsuite.cc
View file @
42092f70
...
@@ -25,11 +25,14 @@ struct PARAM {
...
@@ -25,11 +25,14 @@ struct PARAM {
int
Lmax
;
int
Lmax
;
int
N
;
int
N
;
r_8
R
;
r_8
R
;
int
Pmax
;
//JEC 7/10/15
int
Pmax
;
int
alpha
;
int
alpha
;
string
geometry
;
string
geometry
;
int
ntheta
;
int
ntheta
;
int
nphi
;
int
nphi
;
string
clenshawDir
;
//JEC 23/11/15
string
jlnpDir
;
// "
bool
recomputeJlnp
;
// "
}
param
;
}
param
;
//simple random generator (taken from sharp_testsuite
//simple random generator (taken from sharp_testsuite
...
@@ -293,6 +296,10 @@ void TestLaguerre2Bessel() {
...
@@ -293,6 +296,10 @@ void TestLaguerre2Bessel() {
string
geometry
=
param
.
geometry
;
string
geometry
=
param
.
geometry
;
int
ntheta
=
param
.
ntheta
;
int
ntheta
=
param
.
ntheta
;
int
nphi
=
param
.
nphi
;
int
nphi
=
param
.
nphi
;
string
clenshawDir
=
param
.
clenshawDir
;
//JEC 23/11/15
string
jlnpDir
=
param
.
jlnpDir
;
// "
bool
recomputeJlnp
=
param
.
recomputeJlnp
;
// "
cout
<<
" ______________ TestLaguerre2Bessel TEST ___________ "
<<
endl
;
cout
<<
" ______________ TestLaguerre2Bessel TEST ___________ "
<<
endl
;
...
@@ -374,7 +381,8 @@ void TestLaguerre2Bessel() {
...
@@ -374,7 +381,8 @@ void TestLaguerre2Bessel() {
tstack_push
(
"processing"
);
tstack_push
(
"processing"
);
cout
<<
"tstack 2a Start"
<<
endl
;
cout
<<
"tstack 2a Start"
<<
endl
;
tstack_push
(
"Init Laguerre 2 Bessel"
);
tstack_push
(
"Init Laguerre 2 Bessel"
);
Laguerre2Bessel
lag2bess
(
sphere
,
lagTrans
,
Nmax
,
Pmax
,
Rmax
);
Laguerre2Bessel
lag2bess
(
sphere
,
lagTrans
,
Nmax
,
Pmax
,
Rmax
,
clenshawDir
,
jlnpDir
,
recomputeJlnp
);
cout
<<
"tstack 2a End"
<<
endl
;
cout
<<
"tstack 2a End"
<<
endl
;
tstack_pop
(
"Init Laguerre 2 Bessel"
);
tstack_pop
(
"Init Laguerre 2 Bessel"
);
...
@@ -591,7 +599,7 @@ int main(int narg, char *arg[]) {
...
@@ -591,7 +599,7 @@ int main(int narg, char *arg[]) {
int
N
=
128
;
int
N
=
128
;
r_8
R
=
1.
;
r_8
R
=
1.
;
int
Lmax
=
128
;
int
Lmax
=
128
;
int
Pmax
=
0
;
//JEC 7/10/15
int
Pmax
=
0
;
int
test
=
1
;
int
test
=
1
;
...
@@ -599,6 +607,13 @@ int main(int narg, char *arg[]) {
...
@@ -599,6 +607,13 @@ int main(int narg, char *arg[]) {
int
ntheta
=
-
1
;
int
ntheta
=
-
1
;
int
nphi
=
-
1
;
int
nphi
=
-
1
;
//JEC 23/11/15
char
*
pLAGSHTROOTDIR
;
pLAGSHTROOTDIR
=
getenv
(
"LAGSHTROOTDIR"
);
string
clenshawDir
=
string
(
pLAGSHTROOTDIR
)
+
"/data"
;
string
jlnpDir
=
string
(
pLAGSHTROOTDIR
)
+
"/data"
;
bool
recomputeJlnp
=
false
;
int
ka
=
1
;
int
ka
=
1
;
while
(
ka
<
narg
)
{
while
(
ka
<
narg
)
{
if
(
strcmp
(
arg
[
ka
],
"-h"
)
==
0
)
{
if
(
strcmp
(
arg
[
ka
],
"-h"
)
==
0
)
{
...
@@ -644,6 +659,18 @@ int main(int narg, char *arg[]) {
...
@@ -644,6 +659,18 @@ int main(int narg, char *arg[]) {
Pmax
=
atof
(
arg
[
ka
+
1
]);
Pmax
=
atof
(
arg
[
ka
+
1
]);
ka
+=
2
;
ka
+=
2
;
}
}
else
if
(
strcmp
(
arg
[
ka
],
"-clenPath"
)
==
0
)
{
clenshawDir
=
arg
[
ka
+
1
];
ka
+=
2
;
}
else
if
(
strcmp
(
arg
[
ka
],
"-jlnpPath"
)
==
0
)
{
jlnpDir
=
arg
[
ka
+
1
];
ka
+=
2
;
}
else
if
(
strcmp
(
arg
[
ka
],
"-jlnp"
)
==
0
)
{
recomputeJlnp
=
true
;
ka
+=
1
;
}
else
ka
++
;
else
ka
++
;
}
//eo while
}
//eo while
...
@@ -656,6 +683,11 @@ int main(int narg, char *arg[]) {
...
@@ -656,6 +683,11 @@ int main(int narg, char *arg[]) {
param
.
ntheta
=
ntheta
;
param
.
ntheta
=
ntheta
;
param
.
nphi
=
nphi
;
param
.
nphi
=
nphi
;
param
.
clenshawDir
=
clenshawDir
;
param
.
jlnpDir
=
jlnpDir
;
param
.
recomputeJlnp
=
recomputeJlnp
;
cout
<<
"Configuration parameters are set to: "
cout
<<
"Configuration parameters are set to: "
<<
" Test number : "
<<
test
<<
"
\n
"
<<
" Test number : "
<<
test
<<
"
\n
"
<<
" Lmax, Nmax, Pmax, Rmax , alpha: "
<<
" Lmax, Nmax, Pmax, Rmax , alpha: "
...
@@ -665,9 +697,14 @@ int main(int narg, char *arg[]) {
...
@@ -665,9 +697,14 @@ int main(int narg, char *arg[]) {
<<
param
.
R
<<
", "
<<
param
.
R
<<
", "
<<
param
.
alpha
<<
"
\n
"
<<
param
.
alpha
<<
"
\n
"
<<
"Geometry: "
<<
param
.
geometry
<<
" Ntheta, Nphi: "
<<
"Geometry: "
<<
param
.
geometry
<<
" Ntheta, Nphi: "
<<
param
.
ntheta
<<
", "
<<
param
.
nphi
<<
param
.
ntheta
<<
", "
<<
param
.
nphi
<<
"
\n
"
;
<<
endl
;
if
(
recomputeJlnp
){
cout
<<
"rebuild Jlnp:
\n
Clenshaw Path<"
<<
param
.
clenshawDir
<<
">
\n
and jlnp Path<"
<<
param
.
jlnpDir
<<
">"
<<
endl
;
}
else
{
cout
<<
"Jlnp path <"
<<
param
.
jlnpDir
<<
">"
<<
endl
;
}
int
rc
=
0
;
int
rc
=
0
;
try
{
try
{
...
...
src/laguerre2bessel.cc
View file @
42092f70
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
#include "walltimer.h" //timing
#include "walltimer.h" //timing
#include <fstream> //dump
#include <fstream> //dump
#include <sstream>
#define DEBUG 1
namespace
LagSHT
{
namespace
LagSHT
{
...
@@ -16,25 +20,60 @@ namespace LagSHT {
...
@@ -16,25 +20,60 @@ namespace LagSHT {
recursive
recursive
Version 2: Jlnp calcule via une Discrete Fourier-Bessel Transform and a Clenshaw-Curtis quadrature and global integration strategy.
Version 2: Jlnp calcule via une Discrete Fourier-Bessel Transform and a Clenshaw-Curtis quadrature and global integration strategy.
*/
*/
Laguerre2Bessel
::
Laguerre2Bessel
(
BaseGeometry
*
sphere
,
Laguerre2Bessel
::
Laguerre2Bessel
(
BaseGeometry
*
sphere
,
LaguerreTransform
*
lagTrans
,
LaguerreTransform
*
lagTrans
,
int
Nmax
,
int
Pmax
,
r_8
Rmax
int
Nmax
,
int
Pmax
,
r_8
Rmax
,
)
:
string
clenshawDir
,
sphere_
(
sphere
),
lagTrans_
(
lagTrans
),
string
jlnpDir
,
Nmax_
(
Nmax
),
Pmax_
(
Pmax
),
Rmax_
(
Rmax
)
{
bool
recomputeJlnp
)
:
if
(
sphere_
)
{
sphere_
(
sphere
),
lagTrans_
(
lagTrans
),
//store localy usefull parameters for the algorithms Analysis/Synthesis
Nmax_
(
Nmax
),
Pmax_
(
Pmax
),
Rmax_
(
Rmax
),
PPmax_
(
Pmax
)
{
Npix_
=
sphere_
->
Npix
();
Nalm_
=
sphere_
->
Nalm
();
if
(
sphere_
)
{
Lmax_
=
sphere_
->
Lmax
();
//store localy usefull parameters for the algorithms Analysis/Synthesis
Mmax_
=
sphere_
->
Mmax
();
Npix_
=
sphere_
->
Npix
();
}
else
{
Nalm_
=
sphere_
->
Nalm
();
throw
LagSHTError
(
"LaguerreSphericalTransform::Ctor sphere_ ptr NULL"
);
Lmax_
=
sphere_
->
Lmax
();
}
Mmax_
=
sphere_
->
Mmax
();
}
else
{
ComputeJInteg
();
throw
LagSHTError
(
"LaguerreSphericalTransform::Ctor sphere_ ptr NULL"
);
}
jnu_
=
new
Bessel
(
Lmax_
,
max
(
Pmax_
,
PPmax_
));
//the max is here just in case PPmax =/= Pmax
if
(
!
recomputeJlnp
){
//read the Rmax-independant values of the jlnp and rescale
stringstream
ss
;
ss
<<
"jlnp-L"
<<
Lmax_
<<
"-N"
<<
Nmax_
<<
"-P"
<<
Pmax_
<<
"-PP"
<<
PPmax_
<<
".txt"
;
std
::
ifstream
ifs
(
jlnpDir
+
"/"
+
ss
.
str
(),
std
::
ifstream
::
in
);
if
(
!
ifs
.
is_open
())
throw
LagSHTError
(
"ERROR: jlnp file open failed.:"
+
ss
.
str
());
r_8
tau
=
lagTrans_
->
GetTau
();
r_8
tau3sqrt
=
pow
(
tau
,(
r_8
)(
3.
/
2.
));
int
Jstride
=
Lmax_
*
Pmax_
;
// nbre of (l,p) couples
Jlnp_
.
resize
(
Nmax_
*
Jstride
);
int
pcur
,
lcur
,
ncur
;
r_8
val
;
for
(
int
p
=
0
;
p
<
Pmax_
;
p
++
){
for
(
int
l
=
0
;
l
<
Lmax_
;
l
++
){
int
ploff7
=
p
+
l
*
Pmax_
;
for
(
int
n
=
0
;
n
<
Nmax_
;
n
++
){
ifs
>>
lcur
>>
ncur
>>
pcur
>>
val
;
//read
// if( (l!=lcur) || (n!=ncur) || (p!=pcur)) //check
// throw LagSHTError("ERROR: jlnp file read failed.:"+ss.str());
Jlnp_
[
ploff7
+
n
*
Jstride
]
=
tau3sqrt
*
val
;
//rescaling
}
//n
}
//l
}
//p
}
else
{
ComputeJInteg
(
clenshawDir
,
jlnpDir
);
}
//jlnp omputation/load
}
//Ctor
}
//Ctor
...
@@ -54,10 +93,12 @@ namespace LagSHT {
...
@@ -54,10 +93,12 @@ namespace LagSHT {
JEC: 12/11/15 Add the contribution of Integral_{r_{Nmax-1}}^{r_{Nmax-1} + 3(r_{Nmax-1}-r_{Nmax-2})} by Clenshaw-Curtis quadrature
JEC: 12/11/15 Add the contribution of Integral_{r_{Nmax-1}}^{r_{Nmax-1} + 3(r_{Nmax-1}-r_{Nmax-2})} by Clenshaw-Curtis quadrature
*/
*/
void
Laguerre2Bessel
::
ComputeJInteg
(){
void
Laguerre2Bessel
::
ComputeJInteg
(
string
clenshawDir
,
string
jlnpDir
){
r_8
tau
=
lagTrans_
->
GetTau
();
r_8
tau
=
lagTrans_
->
GetTau
();
r_8
tau3sqrt
=
pow
(
tau
,(
r_8
)(
3.
/
2.
));
r_8
tau3sqrt
=
pow
(
tau
,(
r_8
)(
3.
/
2.
));
// cout << "(JEC) tau3sqrt= " << tau3sqrt << endl;
//JEC 12/11/15 Start
//JEC 12/11/15 Start
r_8
rNm1
=
Rmax_
/
tau
;
// R = r[N-1] voir acces direct = (lagTrans_->GetNodes()).back()
r_8
rNm1
=
Rmax_
/
tau
;
// R = r[N-1] voir acces direct = (lagTrans_->GetNodes()).back()
...
@@ -67,14 +108,14 @@ void Laguerre2Bessel::ComputeJInteg(){
...
@@ -67,14 +108,14 @@ void Laguerre2Bessel::ComputeJInteg(){
r_8
integUpperBound
=
rNm1
+
deltaR
;
//for the integral
r_8
integUpperBound
=
rNm1
+
deltaR
;
//for the integral
r_8
tol
=
1e-10
;
r_8
tol
=
1e-10
;
typedef
ClenshawCurtisQuadrature
<
double
>
Integrator_t
;
typedef
ClenshawCurtisQuadrature
<
double
>
Integrator_t
;
Integrator_t
theQuad
(
20
,
"/Users/campagne/Travail/Software/Laguerre/LagSHT/data/ClenshawCurtisRuleData-20.txt"
,
false
);
//false=do not recompute the weights and nodes of the quadrature
string
clenshawFile
=
clenshawDir
+
"/ClenshawCurtisRuleData-20.txt"
;
Integrator_t
theQuad
(
20
,
clenshawFile
,
false
);
//false=do not recompute the weights and nodes of the quadrature
Quadrature
<
r_8
,
Integrator_t
>::
values_t
integ_val
;
Quadrature
<
r_8
,
Integrator_t
>::
values_t
integ_val
;
//JEC 12/11/15 end
//JEC 12/11/15 end
int
Jstride
=
Lmax_
*
Pmax_
;
// nbre of (l,p) couples
int
Jstride
=
Lmax_
*
Pmax_
;
// nbre of (l,p) couples
Jlnp_
.
resize
(
Nmax_
*
Jstride
);
Jlnp_
.
resize
(
Nmax_
*
Jstride
);
//JEC 16/11/15 START: Todo all that might be in common somewhere (hint: laguerreTransform.h)
//JEC 16/11/15 START: Todo all that might be in common somewhere (hint: laguerreTransform.h)
int
alpha
=
lagTrans_
->
GetAlpha
();
int
alpha
=
lagTrans_
->
GetAlpha
();
...
@@ -91,18 +132,16 @@ void Laguerre2Bessel::ComputeJInteg(){
...
@@ -91,18 +132,16 @@ void Laguerre2Bessel::ComputeJInteg(){
//END
//END
int
PPmax
=
1024
;
// Sum maximum To be put in parameter
int
PPmaxm1
=
PPmax_
-
1
;
int
PPmaxm1
=
PPmax
-
1
;
jnu_
=
new
Bessel
(
Lmax_
,
max
(
Pmax_
,
PPmax
));
//To do put it in constructor
tstack_push
(
"J Integ compute "
);
tstack_push
(
"J Integ compute "
);
stringstream
ss
;
ss
<<
"jlnp-L"
<<
Lmax_
<<
"-N"
<<
Nmax_
<<
"-P"
<<
Pmax_
<<
"-PP"
<<
PPmax_
<<
".txt"
;
std
::
ofstream
ofs
;
std
::
ofstream
ofs
;
ofs
.
open
(
"
jlnp
.txt"
,
std
::
ofstream
::
out
);
ofs
.
open
(
jlnp
Dir
+
"/"
+
ss
.
str
()
,
std
::
ofstream
::
out
);
// cout << "(JEC) Jlpn recompute..." << endl;
for
(
int
p
=
0
;
p
<
Pmax_
;
p
++
){
for
(
int
p
=
0
;
p
<
Pmax_
;
p
++
){
for
(
int
l
=
0
;
l
<
Lmax_
;
l
++
){
for
(
int
l
=
0
;
l
<
Lmax_
;
l
++
){
...
@@ -123,7 +162,7 @@ void Laguerre2Bessel::ComputeJInteg(){
...
@@ -123,7 +162,7 @@ void Laguerre2Bessel::ComputeJInteg(){
//contribution of the integral: [0,rNm1] estimated
//contribution of the integral: [0,rNm1] estimated
//using Discrete Fourier-Bessel Transform
//using Discrete Fourier-Bessel Transform
for
(
int
pp
=
0
;
pp
<
PPmax
;
pp
++
){
for
(
int
pp
=
0
;
pp
<
PPmax
_
;
pp
++
){
r_8
qlpp
=
(
*
jnu_
)(
l
,
pp
);
//ql,pp
r_8
qlpp
=
(
*
jnu_
)(
l
,
pp
);
//ql,pp
r_8
jlp1
=
Bessel
::
jn
(
l
+
1
,
qlpp
);
//j(l+1,ql,pp)
r_8
jlp1
=
Bessel
::
jn
(
l
+
1
,
qlpp
);
//j(l+1,ql,pp)
...
@@ -135,23 +174,26 @@ void Laguerre2Bessel::ComputeJInteg(){
...
@@ -135,23 +174,26 @@ void Laguerre2Bessel::ComputeJInteg(){
}
//pp-loop
}
//pp-loop
Jlnp_
[
ploff7
+
n
*
Jstride
]
=
(
coeff
*
sum
)
*
(
tau3sqrt
*
facts
[
n
]);
//
Jlnp_[ploff7 + n*Jstride] = (coeff * sum) * (tau3sqrt*facts[n]);
//JEC 23/11/15 save the Rmax-independant part
Jlnp_
[
ploff7
+
n
*
Jstride
]
=
coeff
*
facts
[
n
]
*
sum
;
//contribution [rNm1, rNm1+deltaR] estimated with Clenshaw-Curtis quadrature (JEC 12/11/15) Start
//contribution [rNm1, rNm1+deltaR] estimated with Clenshaw-Curtis quadrature (JEC 12/11/15) Start
IntFunc1D
f
(
l
,
qlp
/
rNm1
,
Ln
);
IntFunc1D
f
(
l
,
qlp
/
rNm1
,
Ln
);
theQuad
.
SetFuncBounded
(
f
,
integLowerBound
,
integUpperBound
);
theQuad
.
SetFuncBounded
(
f
,
integLowerBound
,
integUpperBound
);
integ_val
=
theQuad
.
GlobalAdapStrat
(
tol
,
2
,
1
);
integ_val
=
theQuad
.
GlobalAdapStrat
(
tol
,
2
,
1
);
Jlnp_
[
ploff7
+
n
*
Jstride
]
+=
integ_val
.
first
*
(
tau3sqrt
*
facts
[
n
]
*
sqrt
(
2.0
/
M_PI
));
// Jlnp_[ploff7 + n*Jstride] += integ_val.first * (tau3sqrt*facts[n]*sqrt(2.0/M_PI));
//JEC 23/11/15 save the Rmax-independant part
Jlnp_
[
ploff7
+
n
*
Jstride
]
+=
integ_val
.
first
*
(
facts
[
n
]
*
sqrt
(
2.0
/
M_PI
));
//End
//JEC 23/11/15 save the Rmax-independant part
ofs
<<
l
<<
" "
ofs
<<
l
<<
" "
<<
n
<<
" "
<<
n
<<
" "
<<
p
<<
" "
<<
setprecision
(
12
)
<<
Jlnp_
[
ploff7
+
n
*
Jstride
]
<<
endl
;
<<
p
<<
" "
<<
setprecision
(
30
)
<<
Jlnp_
[
ploff7
+
n
*
Jstride
]
<<
endl
;
Jlnp_
[
ploff7
+
n
*
Jstride
]
*=
tau3sqrt
;
delete
Ln
;
delete
Ln
;
}
//n
}
//n
...
@@ -161,7 +203,6 @@ void Laguerre2Bessel::ComputeJInteg(){
...
@@ -161,7 +203,6 @@ void Laguerre2Bessel::ComputeJInteg(){
ofs
.
close
();
ofs
.
close
();
tstack_pop
(
"J Integ compute "
);
tstack_pop
(
"J Integ compute "
);
cout
<<
"J Integ compute END"
<<
endl
;
}
//ComputeJlpnInteg
}
//ComputeJlpnInteg
...
@@ -179,9 +220,10 @@ void Laguerre2Bessel::Lag2BessCoeff(const vector< complex<r_8> >& FLlmn,
...
@@ -179,9 +220,10 @@ void Laguerre2Bessel::Lag2BessCoeff(const vector< complex<r_8> >& FLlmn,
int
Jstride
=
Lmax_
*
Pmax_
;
int
Jstride
=
Lmax_
*
Pmax_
;
#if DEBUG>=1
std
::
ofstream
ofs
;
std
::
ofstream
ofs
;
ofs
.
open
(
"FBlmp.txt"
,
std
::
ofstream
::
out
);
ofs
.
open
(
"FBlmp.txt"
,
std
::
ofstream
::
out
);
#endif
//try here a pedestrian computation
//try here a pedestrian computation
for
(
int
p
=
0
;
p
<
Pmax_
;
p
++
){
for
(
int
p
=
0
;
p
<
Pmax_
;
p
++
){
...
@@ -200,17 +242,19 @@ void Laguerre2Bessel::Lag2BessCoeff(const vector< complex<r_8> >& FLlmn,
...
@@ -200,17 +242,19 @@ void Laguerre2Bessel::Lag2BessCoeff(const vector< complex<r_8> >& FLlmn,
}
//n
}
//n
FBlmp
[
idBess
]
=
sum
;
FBlmp
[
idBess
]
=
sum
;
#if DEBUG>=1
ofs
<<
l
<<
" "
ofs
<<
l
<<
" "
<<
m
<<
" "
<<
m
<<
" "
<<
p
<<
" "
<<
setprecision
(
12
)
<<
FBlmp
[
idBess
]
<<
endl
;
<<
p
<<
" "
<<
setprecision
(
12
)
<<
FBlmp
[
idBess
]
<<
endl
;
#endif
}
//m
}
//m
}
//l
}
//l
}
//p
}
//p
#if DEBUG>=1
ofs
.
close
();
ofs
.
close
();
#endif
}
//Transform
}
//Transform
...
@@ -255,6 +299,7 @@ void Laguerre2Bessel::Synthesis(const vector< complex<r_8> >& FBlmp,
...
@@ -255,6 +299,7 @@ void Laguerre2Bessel::Synthesis(const vector< complex<r_8> >& FBlmp,
//pedestrian computation
//pedestrian computation
r_8
fact
=
sqrt
(
2.
*
M_PI
)
/
(
Rmax_
*
Rmax_
*
Rmax_
);
r_8
fact
=
sqrt
(
2.
*
M_PI
)
/
(
Rmax_
*
Rmax_
*
Rmax_
);
vector
<
complex
<
r_8
>
>
sumElmt
(
Pmax_
);
for
(
int
k
=
0
;
k
<
Nmax_
;
k
++
){
for
(
int
k
=
0
;
k
<
Nmax_
;
k
++
){
r_8
rk_red
=
vrk
[
k
]
/
rNm1
;
r_8
rk_red
=
vrk
[
k
]
/
rNm1
;
...
@@ -265,24 +310,6 @@ void Laguerre2Bessel::Synthesis(const vector< complex<r_8> >& FBlmp,
...
@@ -265,24 +310,6 @@ void Laguerre2Bessel::Synthesis(const vector< complex<r_8> >& FBlmp,
int
lmOff7
=
l
+
m
*
Lmax_
-
m
*
(
m
+
1
)
/
2
;
int
lmOff7
=
l
+
m
*
Lmax_
-
m
*
(
m
+
1
)
/
2
;
int
id0
=
k
*
Nalm_
+
lmOff7
;
int
id0
=
k
*
Nalm_
+
lmOff7
;
//JEC 18/11/15 simple summation algo
// complex<r_8> sum = 0.;
// for(int p=0;p<Pmax_;p++){
// r_8 qlp = (*jnu_)(l,p);
// r_8 jlp1 = Bessel::jn(l+1,qlp);
// r_8 kapalp = fact/(jlp1*jlp1);
// int id1 = p*Nalm_ + lmOff7;
// complex<r_8> tmp = kapalp*Bessel::jn(l,qlp*rk_red)*FBlmp[id1];
// sum += tmp;
// }//loop on p
// FBalmk[id0] = sum;
//JEC 18/11/15 Kahan summation algo
vector
<
complex
<
r_8
>
>
sumElmt
(
Pmax_
);
for
(
int
p
=
0
;
p
<
Pmax_
;
p
++
){
//Fill
for
(
int
p
=
0
;
p
<
Pmax_
;
p
++
){
//Fill
r_8
qlp
=
(
*
jnu_
)(
l
,
p
);
r_8
qlp
=
(
*
jnu_
)(
l
,
p
);
r_8
jlp1
=
Bessel
::
jn
(
l
+
1
,
qlp
);
r_8
jlp1
=
Bessel
::
jn
(
l
+
1
,
qlp
);
...
@@ -291,7 +318,7 @@ void Laguerre2Bessel::Synthesis(const vector< complex<r_8> >& FBlmp,
...
@@ -291,7 +318,7 @@ void Laguerre2Bessel::Synthesis(const vector< complex<r_8> >& FBlmp,
sumElmt
[
p
]
=
kapalp
*
Bessel
::
jn
(
l
,
qlp
*
rk_red
)
*
FBlmp
[
id1
];
sumElmt
[
p
]
=
kapalp
*
Bessel
::
jn
(
l
,
qlp
*
rk_red
)
*
FBlmp
[
id1
];
}
}
// FBalmk[id0] = LagSHT::accumulate(sumElmt.begin(),sumElmt.end());
//
kahan summation
FBalmk[id0] = LagSHT::accumulate(sumElmt.begin(),sumElmt.end());
FBalmk
[
id0
]
=
std
::
accumulate
(
sumElmt
.
begin
(),
sumElmt
.
end
(),
complex
<
r_8
>
(
0.
,
0.
));
FBalmk
[
id0
]
=
std
::
accumulate
(
sumElmt
.
begin
(),
sumElmt
.
end
(),
complex
<
r_8
>
(
0.
,
0.
));
}
//loop on m
}
//loop on m
...
...
src/laguerre2bessel.h
View file @
42092f70
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include "laguerreTransform.h"
#include "laguerreTransform.h"
#include "lagsht_spheregeom.h"
#include "lagsht_spheregeom.h"
#include "lagsht_bessel.h"
#include "lagsht_bessel.h"
#include "lagsht_exceptions.h"
#include "quadinteg.h" //JEC 12/11/15
#include "quadinteg.h" //JEC 12/11/15
...
@@ -44,27 +45,27 @@ namespace LagSHT {
...
@@ -44,27 +45,27 @@ namespace LagSHT {
//// --------- Class to transform Spherical Laguerre into Spherical Bessel -- //
//// --------- Class to transform Spherical Laguerre into Spherical Bessel -- //
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//implementation of the Kahan summation algorithm
/*
//implementation of the Kahan summation algorithm
*/
template
<
class
InIt
>
/*
template <class InIt>
*/
typename
std
::
iterator_traits
<
InIt
>::
value_type
accumulate
(
InIt
begin
,
InIt
end
)
{
/*
typename std::iterator_traits<InIt>::value_type accumulate(InIt begin, InIt end) {
*/
typedef
typename
std
::
iterator_traits
<
InIt
>::
value_type
real
;
/*
typedef typename std::iterator_traits<InIt>::value_type real;
*/
real
sum
=
real
();
/*
real sum = real();
*/
real
running_error
=
real
();
/*
real running_error = real();
*/
real
temp
;
/*
real temp;
*/
real
difference
;
/*
real difference;
*/
for
(;
begin
!=
end
;
++
begin
)
{
/*
for (; begin != end; ++begin) {
*/
difference
=
*
begin
;
/*
difference = *begin;
*/
difference
-=
running_error
;
/*
difference -= running_error;
*/
temp
=
sum
;
/*
temp = sum;
*/
temp
+=
difference
;
/*
temp += difference;
*/
running_error
=
temp
;
/*
running_error = temp;
*/
running_error
-=
sum
;
/*
running_error -= sum;
*/
running_error
-=
difference
;
/*
running_error -= difference;
*/
sum
=
std
::
move
(
temp
);
/*
sum = std::move(temp);
*/
}
/*
}
*/
return
sum
;
/*
return sum;
*/
}
/* } */
class
Laguerre2Bessel
{
class
Laguerre2Bessel
{
public:
public:
...
@@ -72,7 +73,11 @@ public:
...
@@ -72,7 +73,11 @@ public:
//! Ctor
//! Ctor
Laguerre2Bessel
(
BaseGeometry
*
sphere
,
Laguerre2Bessel
(
BaseGeometry
*
sphere
,
LaguerreTransform
*
lagTrans
,
LaguerreTransform
*
lagTrans
,
int
Nmax
,
int
Pmax
,
r_8
Rmax
);
int
Nmax
,
int
Pmax
,
r_8
Rmax
,
string
clenshawDir
,
string
jlnpDir
,
bool
recomputeJlnp
=
false
);
//! Destructor
//! Destructor
virtual
~
Laguerre2Bessel
()
{
virtual
~
Laguerre2Bessel
()
{
...
@@ -108,8 +113,10 @@ private:
...
@@ -108,8 +113,10 @@ private:
/*! \brief
/*! \brief
J_{lnp} = J_{ln}(k_{lp})
J_{lnp} = J_{ln}(k_{lp})
= tau^(3/2) \int_0^\infty dx x^2 {\cal L}^{(2)}_n (x) j_l(tau k_{lp} x)
= tau^(3/2) \int_0^\infty dx x^2 {\cal L}^{(2)}_n (x) j_l(tau k_{lp} x)
\input clenshawDir directory to find the Clenshaw-Curtis quadrature weight & nodes
\input jlnpDir Directory where to save the result
*/
*/
void
ComputeJInteg
();
void
ComputeJInteg
(
string
clenshawDir
,
string
jlnpDir
);
/*!
/*!
...
@@ -146,6 +153,8 @@ protected:
...
@@ -146,6 +153,8 @@ protected:
int
Pmax_
;
//!< Max. order of the Bessel coeff.
int
Pmax_
;
//!< Max. order of the Bessel coeff.
r_8
Rmax_
;
//!< Radial maximal value
r_8
Rmax_
;
//!< Radial maximal value
int
PPmax_
;
//!< cut off in the alm computation
Bessel
*<