Search in sources :

Example 1 with OpenMapRealVector

use of org.hipparchus.linear.OpenMapRealVector in project symja_android_library by axkr.

the class SparseArrayExpr method toRealVector.

/**
 * {@inheritDoc}
 */
@Override
public RealVector toRealVector() {
    if (fDimension.length == 1 && fDimension[0] > 0) {
        try {
            OpenMapRealVector result = new OpenMapRealVector(fDimension[0]);
            if (!fDefaultValue.isZero()) {
                double d = fDefaultValue.evalDouble();
                for (int i = 0; i < fDimension[0]; i++) {
                    result.setEntry(i, d);
                }
            }
            for (TrieNode<int[], IExpr> entry : fData.nodeSet()) {
                int[] key = entry.getKey();
                IExpr value = entry.getValue();
                result.setEntry(key[0] - 1, value.evalDouble());
            }
            return result;
        } catch (ArgumentTypeException rex) {
        }
    }
    return null;
}
Also used : OpenMapRealVector(org.hipparchus.linear.OpenMapRealVector) IExpr(org.matheclipse.core.interfaces.IExpr) ArgumentTypeException(org.matheclipse.core.eval.exception.ArgumentTypeException)

Aggregations

OpenMapRealVector (org.hipparchus.linear.OpenMapRealVector)1 ArgumentTypeException (org.matheclipse.core.eval.exception.ArgumentTypeException)1 IExpr (org.matheclipse.core.interfaces.IExpr)1