Ejemplo n.º 1
0
        /// <summary>
        /// Returns the transposed coordinate storage.
        /// </summary>
        /// <param name="alloc">If true, clone storage arrays, otherwise just swap the references and re-use the arrays.</param>
        /// <returns>The transposed storage.</returns>
        public CoordinateStorage <T> Transpose(bool alloc = false)
        {
            var result = new CoordinateStorage <T>(ncols, nrows, nzmax, alloc);

            result.nz    = nz;
            result.nzmax = nzmax;

            // Transposing is just a matter of switching row and column indices.
            if (alloc)
            {
                Array.Copy(rowind, result.colind, nz);
                Array.Copy(colind, result.rowind, nz);
                Array.Copy(values, result.values, nz);
            }
            else
            {
                result.rowind = colind;
                result.colind = rowind;
                result.values = values;
            }

            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new sparse matrix as a copy of the given coordinate storage.
 /// </summary>
 public static CompressedColumnStorage <T> OfIndexed(CoordinateStorage <T> coordinateStorage)
 {
     return(Converter.ToCompressedColumnStorage(coordinateStorage));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new sparse matrix as a copy of the given coordinate storage.
 /// </summary>
 public static CompressedColumnStorage <T> OfIndexed(CoordinateStorage <T> coordinateStorage, bool inplace = false)
 {
     return(Converter.ToCompressedColumnStorage_(coordinateStorage, true, inplace));
 }