/// <summary> /// Solves a system of linear equations, <b>AX = B</b>, with A SVD factorized. /// </summary> /// <param name="input">The right hand side <see cref="Matrix{T}"/>, <b>B</b>.</param> /// <returns>The left hand side <see cref="Matrix{T}"/>, <b>X</b>.</returns> public virtual Matrix <T> Solve(Matrix <T> input) { // Check for proper arguments. if (input == null) { throw new ArgumentNullException("input"); } if (!ComputeVectors) { throw new InvalidOperationException(Resources.SingularVectorsNotComputed); } var result = MatrixU.CreateMatrix(MatrixVT.ColumnCount, input.ColumnCount); Solve(input, result); return(result); }
/// <summary>Returns the singular values as a diagonal <see cref="Matrix{T}"/>.</summary> /// <returns>The singular values as a diagonal <see cref="Matrix{T}"/>.</returns> public Matrix <T> W() { var rows = MatrixU.RowCount; var columns = MatrixVT.ColumnCount; var result = MatrixU.CreateMatrix(rows, columns); for (var i = 0; i < rows; i++) { for (var j = 0; j < columns; j++) { if (i == j) { result.At(i, i, VectorS[i]); } } } return(result); }