/** * Construct a vector by appending a vector to this vector. * @param v vector to append to this one. * @return a new vector */ public ArrayRealVector append(ArrayRealVector v) { return new ArrayRealVector(this, v); }
/** * Creates a {@link RealVector} using the data from the input array. * * @param data the input data * @return a data.length RealVector * @throws IllegalArgumentException if <code>data</code> is empty * @throws NullPointerException if <code>data</code>is null */ public static RealVector createRealVector(double[] data) { return new ArrayRealVector(data, true); }
/** {@inheritDoc} */ @Override public AbstractRealVector copy() { return new ArrayRealVector(this, true); }
/** * @param n Normal vector characterizing a surface element * of the microsphere. */ MicrosphereSurfaceElement(double[] n) { normal = new ArrayRealVector(n); }
/** {@inheritDoc} */ public RealVector append(RealVector v) { try { return new ArrayRealVector(this, (ArrayRealVector) v); } catch (ClassCastException cce) { return new ArrayRealVector(this, v); } }
/** {@inheritDoc} */ public RealVector append(double in) { final double[] out = new double[data.length + 1]; System.arraycopy(data, 0, out, 0, data.length); out[data.length] = in; return new ArrayRealVector(out, false); }
/** {@inheritDoc} */ public RealVector getRowVector(final int row) throws MatrixIndexException { return new ArrayRealVector(getRow(row), false); }
/** * Construct an exception indicating the argument value * that caused the function evaluation to fail. * * @param argument the failing function argument * @since 2.0 */ public FunctionEvaluationException(double[] argument) { super(LocalizedFormats.EVALUATION_FAILED, new ArrayRealVector(argument)); this.argument = argument.clone(); }
/** {@inheritDoc} */ public RealVector getColumnVector(final int column) throws MatrixIndexException { return new ArrayRealVector(getColumn(column), false); }
/** {@inheritDoc} */ @Override public RealVector projection(double[] v) { return projection(new ArrayRealVector(v, false)); }
/** {@inheritDoc} */ @Override public RealVector projection(double[] v) { return projection(new ArrayRealVector(v, false)); }
/** {@inheritDoc} */ public RealVector getSubVector(int index, int n) { ArrayRealVector out = new ArrayRealVector(n); try { System.arraycopy(data, index, out.data, 0, n); } catch (IndexOutOfBoundsException e) { checkIndex(index); checkIndex(index + n - 1); } return out; }
/** {@inheritDoc} */ @Override public RealVector ebeMultiply(double[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); double[] out = data.clone(); for (int i = 0; i < data.length; i++) { out[i] *= v[i]; } return new ArrayRealVector(out, false); }
/** Solve the linear equation A × X = B. * <p>The A matrix is implicit here. It is </p> * @param b right-hand side of the equation A × X = B * @return a vector X that minimizes the two norm of A × X - B * @throws IllegalArgumentException if matrices dimensions don't match * @throws InvalidMatrixException if decomposed matrix is singular */ public ArrayRealVector solve(ArrayRealVector b) throws IllegalArgumentException, InvalidMatrixException { return new ArrayRealVector(solve(b.getDataRef()), false); }
/** Solve the linear equation A × X = B. * <p>The A matrix is implicit here. It is </p> * @param b right-hand side of the equation A × X = B * @return a vector X such that A × X = B * @exception IllegalArgumentException if matrices dimensions don't match * @exception InvalidMatrixException if decomposed matrix is singular */ public ArrayRealVector solve(ArrayRealVector b) throws IllegalArgumentException, InvalidMatrixException { return new ArrayRealVector(solve(b.getDataRef()), false); }
/** {@inheritDoc} */ @Override public RealVector subtract(double[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); double[] out = data.clone(); for (int i = 0; i < data.length; i++) { out[i] -= v[i]; } return new ArrayRealVector(out, false); }
/** Solve the linear equation A × X = B. * <p>The A matrix is implicit here. It is </p> * @param b right-hand side of the equation A × X = B * @return a vector X such that A × X = B * @exception IllegalArgumentException if matrices dimensions don't match * @exception InvalidMatrixException if decomposed matrix is singular */ public ArrayRealVector solve(ArrayRealVector b) throws IllegalArgumentException, InvalidMatrixException { return new ArrayRealVector(solve(b.getDataRef()), false); }
/** {@inheritDoc} */ @Override public RealVector subtract(double[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); double[] out = data.clone(); for (int i = 0; i < data.length; i++) { out[i] -= v[i]; } return new ArrayRealVector(out, false); }
/** {@inheritDoc} */ public RealVector add(double[] v) throws IllegalArgumentException { double[] result = v.clone(); Iterator<Entry> it = sparseIterator(); Entry e; while (it.hasNext() && (e = it.next()) != null) { result[e.getIndex()] += e.getValue(); } return new ArrayRealVector(result, false); }
/** {@inheritDoc} */ public RealVector subtract(double[] v) throws IllegalArgumentException { double[] result = v.clone(); Iterator<Entry> it = sparseIterator(); Entry e; while (it.hasNext() && (e = it.next()) != null) { final int index = e.getIndex(); result[index] = e.getValue() - result[index]; } return new ArrayRealVector(result, false); }