示例#1
0
 /// <summary>
 ///   Converts the string representation of a matrix to its
 ///   double-precision floating-point number matrix equivalent.
 ///   A return value indicates whether the conversion succeeded or failed.
 /// </summary>
 /// <param name="s">The string representation of the matrix.</param>
 /// <param name="provider">
 ///   The format provider to use in the conversion. Default is to use
 ///   <see cref="DefaultMatrixFormatProvider.CurrentCulture"/>.
 /// </param>
 /// <param name="matrix">A double-precision floating-point number matrix parsed
 /// from the given string using the given format provider.</param>
 /// <result>When this method returns, contains the double-precision floating-point
 /// number matrix equivalent to the <see param="s"/> parameter, if the conversion succeeded,
 /// or null if the conversion failed. The conversion fails if the <see param="s"/> parameter
 /// is null, is not a matrix in a valid format, or contains elements which represent
 /// a number less than MinValue or greater than MaxValue. This parameter is passed
 /// uninitialized. </result>
 ///
 public static bool TryParse(string s, IMatrixFormatProvider provider, out double[][] matrix)
 {
     return(Jagged.TryParse(s, provider, out matrix));
 }
 /// <summary>
 ///   Applies a function to every element of the array.
 /// </summary>
 ///
 public static TResult[][] Apply <TInput, TResult>(this TInput[][] matrix, Func <TInput, int, int, TResult> func)
 {
     return(Apply(matrix, func, Jagged.CreateAs <TInput, TResult>(matrix)));
 }
示例#3
0
 public static double[][] ParseJagged(string s, IMatrixFormatProvider provider)
 {
     return(Jagged.Parse(s, provider));
 }
示例#4
0
        /// <summary>
        ///   Sets a region of a matrix to the given values.
        /// </summary>
        ///
        /// <param name="destination">The matrix where elements will be set.</param>
        /// <param name="value">The matrix of values to which matrix elements will be set.</param>
        /// <param name="rowIndices">Array of row indices</param>
        /// <param name="columnIndices">Array of column indices</param>
        ///
        public static void Set <T>(this T[][] destination, T value, int[] rowIndices, int[] columnIndices)
        {
            var values = Jagged.Create <T>(destination.Rows(), destination.Columns(), value);

            set(destination, rowIndices, columnIndices, values, rowIndices, columnIndices);
        }
示例#5
0
 /// <summary>
 ///   Sets a region of a matrix to the given values.
 /// </summary>
 ///
 /// <param name="destination">The matrix where elements will be set.</param>
 /// <param name="value">The value to which matrix elements will be set.</param>
 ///
 public static void Set <T>(this T[][] destination, T value)
 {
     Set(destination, Jagged.Create(destination.Rows(), destination.Columns(), value));
 }
示例#6
0
 /// <summary>
 ///   Sets a region of a matrix to the given values.
 /// </summary>
 ///
 /// <param name="destination">The matrix where elements will be set.</param>
 /// <param name="value">The matrix of values to which matrix elements will be set.</param>
 /// <param name="rowIndices">Array of row indices</param>
 /// <param name="startColumn">Start column index</param>
 /// <param name="endColumn">End column index</param>
 ///
 public static void Set <T>(this T[][] destination, T value, int[] rowIndices, int startColumn, int endColumn)
 {
     Set(destination, Jagged.Create(destination.Rows(), destination.Columns(), value), rowIndices, startColumn, endColumn);
 }
示例#7
0
 /// <summary>
 ///   Sets a region of a matrix to the given values.
 /// </summary>
 ///
 /// <param name="destination">The matrix where elements will be set.</param>
 /// <param name="value">The matrix of values to which matrix elements will be set.</param>
 /// <param name="startRow">Starting row index</param>
 /// <param name="endRow">End row index</param>
 /// <param name="columnIndices">Array of column indices</param>
 ///
 public static void Set <T>(this T[][] destination, T value, int startRow, int endRow, int[] columnIndices)
 {
     T[][] source = Jagged.Create(destination.Rows(), destination.Columns(), value);
     Set(destination, source, startRow, endRow, columnIndices);
 }
示例#8
0
 public static T[][] Diagonal <T>(int rows, int cols, T[] values)
 {
     return(Diagonal(rows, cols, values, Jagged.Create <T>(rows, cols)));
 }
示例#9
0
 /// <summary>
 ///   Transforms a vector into a matrix of given dimensions.
 /// </summary>
 ///
 public static T[][] Reshape <T>(T[] array, int rows, int cols, MatrixOrder order = MatrixOrder.Default)
 {
     return(Jagged.Reshape(array, rows, cols, Jagged.Create <T>(rows, cols), order));
 }
示例#10
0
 public static T[][] Diagonal <T>(int size, T value)
 {
     return(Diagonal(size, value, Jagged.Create <T>(size, size)));
 }
示例#11
0
 public static T[][] Diagonal <T>(T[] values)
 {
     return(Diagonal(values, Jagged.Create <T>(values.Length, values.Length)));
 }
示例#12
0
 public static double[][] KHot(bool[][] mask, int columns)
 {
     return(KHot(mask, Jagged.Create <double>(mask.Length, columns)));
 }
示例#13
0
 public static double[][] KHot(int[][] indices, int columns)
 {
     return(KHot(indices, Jagged.Create <double>(indices.Length, columns)));
 }
示例#14
0
 public static T[][] KHot <T>(int[][] indices, int columns)
 {
     return(KHot <T>(indices, Jagged.Create <T>(indices.Length, columns)));
 }
示例#15
0
 public static T[][] KHot <T>(bool[][] mask)
 {
     return(KHot <T>(mask, Jagged.CreateAs <bool, T>(mask)));
 }
示例#16
0
 public static T[][] OneHot <T>(bool[] mask)
 {
     return(OneHot <T>(mask, Jagged.Create <T>(mask.Length, 2)));
 }