本文整理汇总了C++中ArrayXd::square方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayXd::square方法的具体用法?C++ ArrayXd::square怎么用?C++ ArrayXd::square使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayXd
的用法示例。
在下文中一共展示了ArrayXd::square方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modeProfileSinc
void Functions::modeProfileSinc(RefArrayXd predictions, const RefArrayXd covariates,
const double centroid, const double height, const double resolution)
{
ArrayXd sincFunctionArgument = Functions::PI*(covariates - centroid)/resolution;
ArrayXd sincFunction = sincFunctionArgument.sin() / sincFunctionArgument;
// Multiply the profile by the height in the PSD
predictions = height*sincFunction.square();
}
示例2: logValue
double MeanNormalLikelihood::logValue(RefArrayXd modelParameters)
{
unsigned long n = observations.size();
double lambda0;
double lambda;
ArrayXd argument;
ArrayXd predictions;
predictions.resize(n);
predictions.setZero();
model.predict(predictions, modelParameters);
argument = (observations - predictions);
argument = argument.square()*weights;
lambda0 = lgammal(n/2.) - log(2) - (n/2.)*log(Functions::PI) + 0.5*weights.log().sum();
lambda = lambda0 - (n/2.)*log(argument.sum());
return lambda;
}
示例3: GuassQaudrature
MatrixXd NumInt::GuassQaudrature(const int& N, double& a, double& b) {
int N0=N-1;
const int N1 = N0+1;
const int N2 = N0+2;
VectorXd xu;
xu.setLinSpaced(N1,-1.0,1.0);
// Legendre-Gauss-Vandermonde Matrix
//Matrix<double,N1,N2> L = Matrix<double,N1,N2>::Zero();
MatrixXd L(N1,N2);
L = MatrixXd::Zero(N1,N2);
// Derivative of Legendre-Gauss-Vandermonde Matrix
//Matrix<double,N1,1> Lp = Matrix<double,N1,1>::Zero();
VectorXd Lp(N1);
Lp = VectorXd::Zero(N1);
VectorXd dum;
dum.setLinSpaced(N1,0.0,N0);
ArrayXd y;
y = cos((2*dum.array()+1)*M_PI/(2*N0+2))+(0.27/N1)*sin(M_PI*xu.array()*N0/N2);
double deps = std::numeric_limits<double>::epsilon();
//Initial Guess
//Array<double,N1,1> y0 = Array<double,N1,1>::Constant(2);
ArrayXd y0 = ArrayXd::Constant(N1,2);
while ((y-y0).abs().matrix().maxCoeff() > deps) {
// L.col(0) = Matrix<double,N1,1>::Constant(1);
L.col(0) = VectorXd::Constant(N1,1);
//Lp = Matrix<double,N1,1>::Zero();
Lp = VectorXd::Zero(N1);
L.col(1) = y;
for (int k=1; k!=N1; k++)
{
L.col(k+1) = ((2*k+1)*L.col(k).cwiseProduct(y.matrix())-k*L.col(k-1))/(k+1);
}
Lp = (N2)*(L.col(N0)-L.col(N1).cwiseProduct(y.matrix())).cwiseQuotient((1-y.square()).matrix());
y0 = y;
y = y0-(L.col(N1).cwiseQuotient(Lp)).array();
}
// Gauss Points
//Matrix<double,N1,1> z = ((a*(1-y)+b*(1+y))/2).matrix();
VectorXd z(N1);
z = ((a*(1-y)+b*(1+y))/2).matrix();
// Gauss Weights
//Matrix<double,N1,1> w;
VectorXd w(N1);
w = (b-a)/(((1-y.square()).matrix()).cwiseProduct(Lp.cwiseProduct(Lp))).array()*pow((double)N2/N1,2);
// Store
//Matrix<double,N1,2> zw;
Matrix<double,Dynamic,Dynamic> zw(N1,2);
zw.col(0)=z;
zw.col(1)=w;
return zw;
}
示例4: variance
const ArrayXd negativeBinomialDist::variance(const ArrayXd &mu) const {
return mu + mu.square()/d_theta;
}
示例5: devResid
const ArrayXd inverseGaussianDist::devResid(const ArrayXd& y, const ArrayXd& mu, const ArrayXd& wt) const {
return wt * ((y - mu).square())/(y * mu.square());
}
示例6:
const ArrayXd gammaDist::variance(const ArrayXd& mu) const {return mu.square();}
示例7: Gaussian
/** @brief Gaussian profile
*
* $f(x) = a exp(\frac{-(x-b)^2}{2 c^2})$
*/
inline VectorXcd
Gaussian(const int N, const int b, const double c, const double a = 1){
ArrayXd dx = ArrayXd::LinSpaced(N, 0, N-1) - b;
VectorXd f = (- dx.square() / (2*c*c)).exp() * a;
return f.cast<std::complex<double>>();
}