18 #ifndef __itkSpecialFunctionGenerator_hxx 19 #define __itkSpecialFunctionGenerator_hxx 23 #include <gsl/gsl_sf_gamma.h> 24 #include <gsl/gsl_sf_laguerre.h> 25 #include <gsl/gsl_sf_bessel.h> 26 #include <gsl/gsl_sf_hyperg.h> 47 return std::tr1::conf_hyperg(a,b,x);
52 Lagurre (
const int n,
const double a,
const T x )
55 return gsl_sf_laguerre_1 (a,x);
57 return gsl_sf_laguerre_2 (a,x);
59 return gsl_sf_laguerre_3 (a,x);
61 return gsl_sf_laguerre_n(n,a,x);
72 return gsl_sf_gamma(x);
78 double gamma_whole =
Gamma(s);
79 double gamma_upper = gsl_sf_gamma_inc(s,x);
80 return gamma_whole - gamma_upper;
87 int int_2a = int(2.0*a);
92 else if (
std::abs(int_2a-2.0*a)<1e-8)
94 utlException (a<0,
"the parameter a should be positive in this routine. \ 95 Note: a can be negative in theory... \n\ 96 When a is an integer, J_a(x)=(-1)^a J_{-a}(x); When a is not an integer, J_a(x) and J_{-a}(x) are linearly independent.");
98 return std::sqrt(2.0*x/
M_PI) * gsl_sf_bessel_jl(
int(a-0.5),x);
101 utlException(
true,
"a should be an integer or a half of an integer!");
111 return gsl_sf_bessel_J0(x);
113 return gsl_sf_bessel_J1(x);
115 return gsl_sf_bessel_Jn(n, x);
179 utl_shared_ptr<utl::NDArray<T,1> >
183 utlException(e1<e2-1e-10,
"e1 should be more than e2, e1="<<e1 <<
", e2="<<e2);
186 typedef utl_shared_ptr<VectorType> VectorPointer;
190 double a = (e1 - e2)*b;
193 for (
int l = 0; l <= lMax; l += 2 )
196 if (std::fabs(theta)<1e-10)
199 (*coef_vec)[jj] = 4.0*
M_PI/(2.0*l+1.0) * expbe2 * A * std::sqrt(1+2*l)/(2*
utl::SQRTPI);
203 for (
int m = -l; m <= l; m += 1 )
214 std::vector< std::vector<T> >
218 utlException(e1<e2-1e-10,
"e1 should be more than e2, e1="<<e1 <<
", e2="<<e2);
220 std::vector<std::vector<T> > coef(2);
224 double a = (e1 - e2)*b;
227 for (
int l = 0; l <= lMax; l += 2 )
231 for (
int m = -l; m <= l; m += 1 )
235 coef[1][jj] = 4.0*
M_PI/(2.0*l+1.0) * expbe2 * (-b) * (A + dA);
255 utl_shared_ptr<utl::NDArray<T,1> >
258 double tau = deltaBig - deltaSmall/3.0;
259 double q_norm = qq*2.0*
M_PI;
260 double a = tau*q_norm*q_norm*diffusivity;
263 typedef utl_shared_ptr<VectorType> VectorPointer;
264 const int m_max = 60;
266 VectorType beta_m = besselJZeros / radius;
272 for (
int m = 0; m < m_max; ++m )
274 double dam = diffusivity*beta_m[m]*beta_m[m];
275 double numerator = 2.0*dam*deltaSmall -2
280 double beta_m2 = beta_m[m]*beta_m[m];
281 double denominator = dam*dam*beta_m2 * (radius*radius*beta_m2 - 1);
283 sum_orth += numerator/denominator;
287 double b = 2.0* q_norm*q_norm/(deltaSmall*deltaSmall) * sum_orth;
290 for (
int l = 0; l <= lMax ; l+=2 )
294 if (std::fabs(theta)<1e-10)
297 (*coef_vec)[jj] = 4.0*
M_PI/(2.0*l+1.0) * A * std::sqrt(1+2*l)/(2*
utl::SQRTPI);
301 for (
int m = -l; m <= l; m += 1 )
321 const double normZ = 2.0*std::sqrt(
M_PI/5.0);
326 for (
int i = 0; i < N; ++i )
327 shCoef2[i] = shCoef[i];
330 SHRotationFilterType::Pointer shRotateFilter = SHRotationFilterType::GetInstance();
334 (shRotateFilter->GetMaxRank()).msg(
"need to set large rank");
341 shCoefRot = shRotateFilter->GetRotatedSHCoefficients(shCoef2, matRot);
354 double sqrtdiff = std::sqrt(diff);
355 double sqrte2 = std::sqrt(e2);
356 double oo = ( sqrtdiff*(2.*e1+e2) - 3.*e1*sqrte2*std::atan(sqrtdiff/sqrte2) ) / (2.0* diff*sqrtdiff);
361 return oo*(1.0+3.*std::cos(2.*phi))/4.0;
static PreciseType RealSH(const int l, const int m, const PreciseType theta, const PreciseType phi)
NDArray is a N-Dimensional array class (row-major, c version)
NDArray<T,1> is a vector class which uses blas mkl.
double BesselJIntegerPrime(const int n, const double x)
void RotationMatrixFromVectors(const VectorType &from, const VectorType &to, MatrixType &mat)
helper functions specifically used in dmritool
double GetExpLegendreCoefDerivative(const double a, const int l, Func1To1 expF=&std::exp)
int GetIndexSHj(const int l, const int m)
double ComputeOrientationalOrderFromSymmetricTensor(const double e1, const double e2, const double phi=0)
double GammaLower(const double s, const double x)
#define utlException(cond, expout)
double GetExpLegendreCoef(const double a, const int l, Func1To1 expF=&std::exp)
NDArray<T,2> is a row-major matrix.
double GetExpProductLegendreCoef(const double a, const double b, const int l)
double Hyperg1F1(double a, double b, double x)
T abs(const T x)
template version of the fabs function
double GetSquaredTwoNorm() const
bool IsInt(const std::string &input, const double epss=1e-10)
T Lagurre(const int n, const double a, const T x)
#define utlSAException(expr)
rotate SH coefficient vector by a given rotation matrix.
int RankToDimSH(const int shRank)
utl_shared_ptr< utl::NDArray< T, 1 > > ComputeDWISHCoefficientsForGPDCylinder(const T radius, const T diffusivity, const T deltaBig, const T deltaSmall, const T qq, const int lMax, const T theta=0, const T phi=0)
double BesselJInteger(const int n, const double x)
bool IsSame(const T &value, const T &v0, const double eps=1e-10)
double GammaHalfInteger(const double x)
std::vector< std::vector< T > > GetSymmetricTensorSHCoefDerivative(const T b, const T e1, const T e2, const int lMax, const T theta=0, const T phi=0)
get the derivatives of the SH coefficients with respect to (e1, e2) in the symmetric tensor with eige...
static constexpr double SQRTPI
double lutExpValue(const double x)
double ComputeOrientationalOrderFromSHCoefficients(const utl::NDArray< T, 1 > &shCoef, const utl::NDArray< T, 1 > &axis)
static const double BesselJPrimeZerosOrder1[60]
double BesselJa(const double a, const double x)
bessel_Ja : Regular Cylindrical Bessel Function
utl_shared_ptr< utl::NDArray< T, 1 > > GetSymmetricTensorSHCoef(const T b, const T e1, const T e2, const int lMax, const T theta=0, const T phi=0)
get the SH coefficients from the symmetric tensor with eigenvalues (e1,e2,e2), e1>e2, and (theta,phi) is the angular direction of the e1 axis.
double Gamma(const double x)
gamma function.