本文整理汇总了Java中org.ejml.data.DenseMatrix64F.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java DenseMatrix64F.wrap方法的具体用法?Java DenseMatrix64F.wrap怎么用?Java DenseMatrix64F.wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ejml.data.DenseMatrix64F
的用法示例。
在下文中一共展示了DenseMatrix64F.wrap方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillInMeanForTaxon
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
private InversionResult fillInMeanForTaxon(final WrappedVector output, final DenseMatrix64F precision, final int taxon) {
final double[] observed = observedIndicators[taxon];
final Parameter Y = traitParameter.getParameter(taxon);
// Solve for a value \mu_i s.t. P_i \mu_i = (L D_i Y_i)
final double[] tmp = new double[numFactors];
final double[] tmp2 = new double[numFactors];
for (int row = 0; row < numFactors; ++row) {
double sum = 0;
for (int k = 0; k < dimTrait; ++k) {
sum += loadings.getParameterValue(k, row) *
observed[k] * traitPrecision.getParameterValue(k) *
Y.getParameterValue(k);
}
tmp[row] = sum;
}
DenseMatrix64F B = DenseMatrix64F.wrap(numFactors, 1, tmp);
DenseMatrix64F X = DenseMatrix64F.wrap(numFactors, 1, tmp2);
InversionResult ci = safeSolve(precision, B, X, true);
for (int row = 0; row < numFactors; ++row) {
output.set(row, X.unsafe_get(row, 0));
}
return ci;
}
示例2: sampleToEigenSpace
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Converts a vector from sample space into eigen space.
*
* @param sampleData Sample space data.
* @return Eigen space projection.
*/
public double[] sampleToEigenSpace( double[] sampleData ) {
if( sampleData.length != A.getNumCols() )
throw new IllegalArgumentException("Unexpected sample length");
DenseMatrix64F mean = DenseMatrix64F.wrap(A.getNumCols(),1,this.mean);
DenseMatrix64F s = new DenseMatrix64F(A.getNumCols(),1,true,sampleData);
DenseMatrix64F r = new DenseMatrix64F(numComponents,1);
CommonOps.subtract(s, mean, s);
CommonOps.mult(V_t,s,r);
return r.data;
}
示例3: eigenToSampleSpace
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Converts a vector from eigen space into sample space.
*
* @param eigenData Eigen space data.
* @return Sample space projection.
*/
public double[] eigenToSampleSpace( double[] eigenData ) {
if( eigenData.length != numComponents )
throw new IllegalArgumentException("Unexpected sample length");
DenseMatrix64F s = new DenseMatrix64F(A.getNumCols(),1);
DenseMatrix64F r = DenseMatrix64F.wrap(numComponents,1,eigenData);
CommonOps.multTransA(V_t,r,s);
DenseMatrix64F mean = DenseMatrix64F.wrap(A.getNumCols(),1,this.mean);
CommonOps.add(s,mean,s);
return s.data;
}
示例4: response
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Computes the dot product of each basis vector against the sample. Can be used as a measure
* for membership in the training sample set. High values correspond to a better fit.
*
* @param sample Sample of original data.
* @return Higher value indicates it is more likely to be a member of input dataset.
*/
public double response( double[] sample ) {
if( sample.length != A.numCols )
throw new IllegalArgumentException("Expected input vector to be in sample space");
DenseMatrix64F dots = new DenseMatrix64F(numComponents,1);
DenseMatrix64F s = DenseMatrix64F.wrap(A.numCols,1,sample);
CommonOps.mult(V_t,s,dots);
return NormOps.normF(dots);
}
示例5: computeStep
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
@Override
protected void computeStep(double[] step)
{
final double[] d1 = gradientProcedure.d1;
final double[] d2 = gradientProcedure.d2;
if (solver != null)
{
// Solve the Jacobian. This is an implementation of the Newton-Raphson method
// for systems of non-linear equations (see Numerical Recipes in C++, 2nd Ed, section 9.6)
// XXX This does not work.
// The the first order derivatives "are not n independent, arbitrary functions,
// rather they obey so-called integrability conditions that are highly restrictive".
// This code is deprecated and may be removed.
for (int i = 0; i < step.length; i++)
step[i] = -d1[i];
jacobianGradientProcedure.getJacobianLinear(jacobian);
DenseMatrix64F m = DenseMatrix64F.wrap(d1.length, d1.length, jacobian);
System.out.println(m.toString());
System.out.println(Arrays.toString(d2));
if (solver.solve(jacobian, step))
{
// XXX - debug the difference
double[] step2 = new double[d1.length];
for (int i = 0; i < step.length; i++)
step2[i] = -d1[i] / d2[i];
System.out.printf("[%d] Jacobian Step %s vs %s\n", tc.getIterations(), Arrays.toString(step),
Arrays.toString(step2));
return;
}
}
// Simple Newton-Raphson update step as per Smith et al, (2010), SI Eq. 13:
// parameter -> new parameter + delta
// => new parameter = parameter - delta
for (int i = 0; i < step.length; i++)
step[i] = -d1[i] / d2[i];
}
示例6: sampleToEigenSpace
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Converts a vector from sample space into eigen space.
*
* @param sampleData Sample space data.
* @return Eigen space projection.
*/
public double[] sampleToEigenSpace( double[] sampleData ) {
if( sampleData.length != A.getNumCols() )
throw new IllegalArgumentException("Unexpected sample length");
DenseMatrix64F mean = DenseMatrix64F.wrap(A.getNumCols(),1,this.mean);
DenseMatrix64F s = new DenseMatrix64F(A.getNumCols(),1,true,sampleData);
DenseMatrix64F r = new DenseMatrix64F(numComponents,1);
CommonOps.sub(s,mean,s);
CommonOps.mult(V_t,s,r);
return r.data;
}
示例7: eigenToSampleSpace
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Converts a vector from eigen space into sample space.
*
* @param eigenData Eigen space data.
* @return Sample space projection.
*/
public double[] eigenToSampleSpace( double[] eigenData ) {
if( eigenData.length != numComponents )
throw new IllegalArgumentException("Unexpected sample length");
DenseMatrix64F s = new DenseMatrix64F(A.getNumCols(),1);
DenseMatrix64F r = DenseMatrix64F.wrap(numComponents,1,eigenData);
CommonOps.multTransA(V_t,r,s);
DenseMatrix64F mean = DenseMatrix64F.wrap(A.getNumCols(),1,this.mean);
CommonOps.add(s,mean,s);
return s.data;
}
示例8: response
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Computes the dot product of each basis vector against the sample. Can be used as a measure
* for membership in the training sample set. High values correspond to a better fit.
*
* @param sample Sample of original data.
* @return Higher value indicates it is more likely to be a member of input dataset.
*/
public double response( double[] sample ) {
if( sample.length != A.numCols )
throw new IllegalArgumentException("Expected input vector to be in sample space");
DenseMatrix64F dots = new DenseMatrix64F(numComponents,1);
DenseMatrix64F s = DenseMatrix64F.wrap(A.numCols,1,sample);
CommonOps.mult(V_t,s,dots);
return NormOps.normF(dots);
}
示例9: wrap
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
public static DenseMatrix64F wrap(final double[] source, final int offset,
final int numRows, final int numCols,
final double[] buffer) {
System.arraycopy(source, offset, buffer, 0, numRows * numCols);
return DenseMatrix64F.wrap(numRows, numCols, buffer);
}
示例10: compute
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Compute the coefficients given the spline node value at interpolated points. The value should be interpolated at
* [0,1/3,2/3,1] in each dimension.
*
* @param value
* the value (packed in order : i = z*16+4*y+x) for x,y,z in [0,1,2,3])
* @return the coefficients (or null if computation failed)
*/
public double[] compute(double[] value)
{
DenseMatrix64F B = DenseMatrix64F.wrap(64, 1, value);
solver.solve(B, B);
return B.data;
}
示例11: toA
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Create a new DenseMatrix from the input matrix a. Modifications to the matrix are passed through to the input
* array!
* <p>
* This is provided as a bridge method between the functions that accept primitive arrays and those that accept
* DenseMatrix.
*
* @param a
* the matrix
* @param n
* the number of columns/rows
* @return the dense matrix
*/
public static DenseMatrix64F toA(double[] a, int n)
{
return DenseMatrix64F.wrap(n, n, a);
}
示例12: toB
import org.ejml.data.DenseMatrix64F; //导入方法依赖的package包/类
/**
* Wrap the input array b in a DenseMatrix. Modifications to the matrix are passed through to the input array.
* <p>
* This is provided as a bridge method between the functions that accept primitive arrays and those that accept
* DenseMatrix.
*
* @param b
* the array
* @return the dense matrix
*/
public static DenseMatrix64F toB(double[] b)
{
return DenseMatrix64F.wrap(b.length, 1, b);
}