Beispiel #1
0
        public virtual DMatrixRMaj extract()
        {
            DMatrixRMaj ret = new DMatrixRMaj(row1 - row0, col1 - col0);

            for (int i = 0; i < ret.numRows; i++)
            {
                for (int j = 0; j < ret.numCols; j++)
                {
                    ret.set(i, j, get(i, j));
                }
            }

            return(ret);
        }
Beispiel #2
0
        /**
         * Give a string of numbers it returns a DenseMatrix
         */
        //@SuppressWarnings("StringSplitter")
        public static DMatrixRMaj parse_DDRM(String s, int numColumns)
        {
            String[] vals = s.Split("(\\s)+");

            // there is the possibility the first element could be empty
            int start = String.IsNullOrEmpty(vals[0]) ? 1 : 0;

            // covert it from string to doubles
            int numRows = (vals.Count() - start) / numColumns;

            DMatrixRMaj ret = new DMatrixRMaj(numRows, numColumns);

            int index = start;

            for (int i = 0; i < numRows; i++)
            {
                for (int j = 0; j < numColumns; j++)
                {
                    ret.set(i, j, Double.Parse(vals[index++]));
                }
            }

            return(ret);
        }