### Question:
JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsIterator = ratingVector.iterateNonZero(); int index = 0; while (ratingsIterator.hasNext()) { Vector.Element elem = ratingsIterator.next(); RiIiMaybeTransposed[index++] = elem.get(); } return new DoubleMatrix(numRatings, 1, RiIiMaybeTransposed); } private  JBlasAlternatingLeastSquaresSolver(); static Vector solve(Iterable<Vector> featureVectors, Vector ratingVector, double lambda, int numFeatures);  }### Answer:
@Test public void createRiIiMaybeTransposed() { Vector ratings = new SequentialAccessSparseVector(3); ratings.setQuick(1, 1.0); ratings.setQuick(3, 3.0); ratings.setQuick(5, 5.0); DoubleMatrix riIiMaybeTransposed = JBlasAlternatingLeastSquaresSolver.createRiIiMaybeTransposed(ratings); assertEquals(1, riIiMaybeTransposed.columns, 1); assertEquals(3, riIiMaybeTransposed.rows, 3); assertEquals(1.0, riIiMaybeTransposed.get(0, 0), EPSILON); assertEquals(3.0, riIiMaybeTransposed.get(1, 0), EPSILON); assertEquals(5.0, riIiMaybeTransposed.get(2, 0), EPSILON); }
@Test public void createRiIiMaybeTransposedExceptionOnNonSequentialVector() { Vector ratings = new RandomAccessSparseVector(3); ratings.setQuick(1, 1.0); ratings.setQuick(3, 3.0); ratings.setQuick(5, 5.0); try { JBlasAlternatingLeastSquaresSolver.createRiIiMaybeTransposed(ratings); fail(); } catch (IllegalArgumentException e) {} }