@Override public int getDimensionality() { return this.internalVector.size(); }
@Override public int getDimensionality() { return this.internalVector.size(); }
/** * Constructor for AbstractVector, same size as x * * @param x * Vector to get the size from */ protected AbstractVector(Vector x) { this.size = x.size(); }
@Override public int getDimensionality() { return this.internalVector.size(); }
/** * Constructor for AbstractVector, same size as x * * @param x * Vector to get the size from */ protected AbstractVector(Vector x) { this.size = x.size(); }
@Override public int length() { return wrapped.size(); }
/** * Checks the arguments to <code>transMult</code> and * <code>transMultAdd</code> */ protected void checkTransMultAdd(Vector x, Vector y) { if (numRows != x.size()) throw new IndexOutOfBoundsException("A.numRows != x.size (" + numRows + " != " + x.size() + ")"); if (numColumns != y.size()) throw new IndexOutOfBoundsException("A.numColumns != y.size (" + numColumns + " != " + y.size() + ")"); }
/** * Checks the arguments to <code>mult</code> and <code>multAdd</code> */ protected void checkMultAdd(Vector x, Vector y) { if (numColumns != x.size()) throw new IndexOutOfBoundsException("A.numColumns != x.size (" + numColumns + " != " + x.size() + ")"); if (numRows != y.size()) throw new IndexOutOfBoundsException("A.numRows != y.size (" + numRows + " != " + y.size() + ")"); }
/** * Checks the arguments to <code>transMult</code> and * <code>transMultAdd</code> */ protected void checkTransMultAdd(Vector x, Vector y) { if (numRows != x.size()) throw new IndexOutOfBoundsException("A.numRows != x.size (" + numRows + " != " + x.size() + ")"); if (numColumns != y.size()) throw new IndexOutOfBoundsException("A.numColumns != y.size (" + numColumns + " != " + y.size() + ")"); }
/** * Checks the arguments to <code>mult</code> and <code>multAdd</code> */ protected void checkMultAdd(Vector x, Vector y) { if (numColumns != x.size()) throw new IndexOutOfBoundsException("A.numColumns != x.size (" + numColumns + " != " + x.size() + ")"); if (numRows != y.size()) throw new IndexOutOfBoundsException("A.numRows != y.size (" + numRows + " != " + y.size() + ")"); }
/** * Checks sizes of input data for {@link #solve(Matrix, Vector, Vector)}. * Throws an exception if the sizes does not match. */ protected void checkSizes(Matrix A, Vector b, Vector x) { if (!A.isSquare()) throw new IllegalArgumentException("!A.isSquare()"); if (b.size() != A.numRows()) throw new IllegalArgumentException("b.size() != A.numRows()"); if (b.size() != x.size()) throw new IllegalArgumentException("b.size() != x.size()"); }
/** * Checks sizes of input data for {@link #solve(Matrix, Vector, Vector)}. * Throws an exception if the sizes does not match. */ protected void checkSizes(Matrix A, Vector b, Vector x) { if (!A.isSquare()) throw new IllegalArgumentException("!A.isSquare()"); if (b.size() != A.numRows()) throw new IllegalArgumentException("b.size() != A.numRows()"); if (b.size() != x.size()) throw new IllegalArgumentException("b.size() != x.size()"); }
private static int length(Vector vec) { if (vec instanceof SparseVector) { return ((SparseVector) vec).getUsed(); } else { return vec.size(); } } }
/** * Populates a vector with random numbers drawn from a uniform distribution * between 0 and 1 * * @param x * Vector to populate */ public static Vector random(Vector x) { for (int i = 0; i < x.size(); ++i) x.set(i, Math.random()); return x; }
/** * Returns a dense array containing a copy of the given vector */ public static double[] getArray(Vector x) { double[] xd = new double[x.size()]; for (VectorEntry e : x) xd[e.index()] = e.get(); return xd; }
/** * Returns a dense array containing a copy of the given vector */ public static double[] getArray(Vector x) { double[] xd = new double[x.size()]; for (VectorEntry e : x) xd[e.index()] = e.get(); return xd; }
protected Vector initScoreVector(int tokenSize) { Vector scoreVector = new DenseVector(tokenSize); double initValue = 1.0; for (int i = 0; i < scoreVector.size(); i++) { scoreVector.set(i, initValue); } return scoreVector; }
/** * Returns the log of the density value for the given vector. * * @param valuePassed input vector * @return log density based on given distribution */ @Override public double logDensity(double[] valuePassed) { // calculate mean subtractions Vector x = new DenseVector(valuePassed); return lnconstant - 0.5 * x.dot(covarianceInverse.mult(x.add(-1.0, mean), new DenseVector(x.size()))); }