use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class Blas method syr.
/**
* A := alpha * x * x^T + A.
*
* @param alpha a real scalar that will be multiplied to x * x^T^.
* @param x the vector x that contains the n elements.
* @param a the symmetric matrix A. Size of n x n.
*/
void syr(Double alpha, Vector x, DenseMatrix a) {
int mA = a.rowSize();
int nA = a.columnSize();
if (mA != nA)
throw new NonSquareMatrixException(mA, nA);
if (mA != x.size())
throw new CardinalityException(x.size(), mA);
// TODO: IGNITE-5535, Process DenseLocalOffHeapVector
if (x instanceof DenseVector)
syr(alpha, x, a);
else if (x instanceof SparseVector)
syr(alpha, x, a);
else
throw new IllegalArgumentException("Operation 'syr' does not support vector [class=" + x.getClass().getName() + "].");
}
use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class AbstractMatrix method getCol.
/**
* {@inheritDoc}
*/
@Override
public Vector getCol(int col) {
checkColumnIndex(col);
Vector res;
res = new DenseVector(rowSize());
for (int i = 0; i < rowSize(); i++) res.setX(i, getX(i, col));
return res;
}
use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class AbstractMatrix method getRow.
/**
* {@inheritDoc}
*/
@Override
public Vector getRow(int row) {
checkRowIndex(row);
Vector res = new DenseVector(columnSize());
for (int i = 0; i < columnSize(); i++) res.setX(i, getX(row, i));
return res;
}
use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class LocalModelsTest method importExportLinearRegressionModelTest.
/**
*/
@Test
public void importExportLinearRegressionModelTest() throws IOException {
executeModelTest(mdlFilePath -> {
LinearRegressionModel mdl = new LinearRegressionModel(new DenseVector(new double[] { 1, 2 }), 3);
Exporter<LinearRegressionModel, String> exporter = new FileExporter<>();
mdl.saveModel(exporter, mdlFilePath);
LinearRegressionModel load = exporter.load(mdlFilePath);
Assert.assertNotNull(load);
Assert.assertEquals("", mdl, load);
return null;
});
}
use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class LocalModelsTest method importExportLogisticRegressionModelTest.
/**
*/
@Test
public void importExportLogisticRegressionModelTest() throws IOException {
executeModelTest(mdlFilePath -> {
LogisticRegressionModel mdl = new LogisticRegressionModel(new DenseVector(new double[] { 1, 2 }), 3);
Exporter<LogisticRegressionModel, String> exporter = new FileExporter<>();
mdl.saveModel(exporter, mdlFilePath);
LogisticRegressionModel load = exporter.load(mdlFilePath);
Assert.assertNotNull(load);
Assert.assertEquals("", mdl, load);
return null;
});
}
Aggregations