Пример #1
0
        /**
         * <p>
         * Converts matrix data stored is a row major format into a block row major format in place.
         * </p>
         *
         * @param numRows number of rows in the matrix.
         * @param numCols number of columns in the matrix.
         * @param blockLength Block size in the converted matrix.
         * @param data Matrix data in a row-major format. Modified.
         * @param workspace Optional internal workspace. Nullable.
         */
        public static void convertRowToBlock(int numRows, int numCols, int blockLength,
                                             double[] data, DGrowArray workspace)
        {
            //int minLength = Math.Min(blockLength, numRows) * numCols;
            //double[] tmp = UtilEjml.adjust(workspace, minLength);

            //for (int i = 0; i < numRows; i += blockLength)
            //{
            //    int blockHeight = Math.Min(blockLength, numRows - i);

            //    System.Array.Copy(data, i * numCols, tmp, 0, blockHeight * numCols);


            //    for (int j = 0; j < numCols; j += blockLength)
            //    {
            //        int blockWidth = Math.Min(blockLength, numCols - j);

            //        int indexDst = i * numCols + blockHeight * j;
            //        int indexSrcRow = j;

            //        for (int k = 0; k < blockHeight; k++)
            //        {
            //            System.Array.Copy(tmp, indexSrcRow, data, indexDst, blockWidth);
            //            indexDst += blockWidth;
            //            indexSrcRow += numCols;
            //        }
            //    }
            //}
        }
Пример #2
0
        /**
         * Converts a row major block matrix into a row major matrix. Both matrices will contain
         * the same data array. Useful when you wish to avoid declaring two large matrices.
         *
         * @param src Original DMatrixRBlock. Modified.
         * @param dst Equivalent DMatrixRMaj. Modified.
         */
        public static DMatrixRMaj convertInplace(DMatrixRBlock src, DMatrixRMaj dst,
                                                 DGrowArray workspace)
        {
            if (dst == null)
            {
                dst = new DMatrixRMaj();
            }

            dst.data    = src.data;
            dst.numRows = src.numRows;
            dst.numCols = src.numCols;
            convertBlockToRow(src.numRows, src.numCols, src.blockLength, src.data, workspace);

            return(dst);
        }
Пример #3
0
        /**
         * Converts a row major matrix into a row major block matrix. Both matrices will contain
         * the same data array. Useful when you wish to avoid declaring two large matrices.
         *
         * @param src Original DMatrixRMaj. Modified.
         * @param dst Equivalent DMatrixRBlock. Modified.
         */
        public static DMatrixRBlock convertInplace(DMatrixRMaj src, DMatrixRBlock dst,
                                                   DGrowArray workspace)
        {
            if (dst == null)
            {
                dst = new DMatrixRBlock();
            }

            dst.data        = src.data;
            dst.blockLength = EjmlParameters.BLOCK_WIDTH;
            dst.numRows     = src.numRows;
            dst.numCols     = src.numCols;
            convertRowToBlock(src.numRows, src.numCols, dst.blockLength, src.data, workspace);

            return(dst);
        }
 public void setTo(DGrowArray original)
 {
     reshape(original.length2);
     System.Array.Copy(original.data, 0, data, 0, original.length2);
 }