コード例 #1
0
        /// <summary>
        /// Returns a string representation of the given matrix with axis as well as rows and columns labeled.
        /// Pass <i>null</i> to one or more parameters to indicate that the corresponding decoration element shall not appear in the string converted matrix.
        /// </summary>
        /// <param name="matrix">The matrix to format.</param>
        /// <param name="sliceNames">The headers of all slices (to be put above each slice).</param>
        /// <param name="rowNames">The headers of all rows (to be put to the left of the matrix).</param>
        /// <param name="columnNames">The headers of all columns (to be put to above the matrix).</param>
        /// <param name="sliceAxisName">The label of the z-axis (to be put above each slice).</param>
        /// <param name="rowAxisName">The label of the y-axis.</param>
        /// <param name="columnAxisName">The label of the x-axis.</param>
        /// <param name="title">The overall title of the matrix to be formatted.</param>
        /// <returns>the matrix converted to a string.</returns>
        private String XToTitleString(DoubleMatrix3D matrix, String[] sliceNames, String[] rowNames, String[] columnNames, String sliceAxisName, String rowAxisName, String columnAxisName, String title)
        {
            if (matrix.Size == 0)
            {
                return("Empty matrix");
            }
            StringBuilder buf = new StringBuilder();

            for (int i = 0; i < matrix.Slices; i++)
            {
                if (i != 0)
                {
                    buf.Append(sliceSeparator);
                }
                buf.Append(ToTitleString(matrix.ViewSlice(i), rowNames, columnNames, rowAxisName, columnAxisName, title + "\n" + sliceAxisName + "=" + sliceNames[i]));
            }
            return(buf.ToString());
        }
コード例 #2
0
        /// <summary>
        /// Returns a string representation of the given matrix.
        /// </summary>
        /// <param name="matrix">the matrix to convert.</param>
        /// <returns>A string representation of the given matrix.</returns>
        public String ToString(DoubleMatrix3D matrix)
        {
            var     buf           = new StringBuilder();
            Boolean oldPrintShape = this.printShape;

            this.printShape = false;
            for (int slice = 0; slice < matrix.Slices; slice++)
            {
                if (slice != 0)
                {
                    buf.Append(sliceSeparator);
                }
                buf.Append(ToString((AbstractMatrix2D)matrix.ViewSlice(slice)));
            }
            this.printShape = oldPrintShape;
            if (printShape)
            {
                buf.Insert(0, Shape(matrix) + "\n");
            }
            return(buf.ToString());
        }
コード例 #3
0
ファイル: Sorting.cs プロジェクト: cobaltblueocean/Colt.NET
        public DoubleMatrix3D Sort(DoubleMatrix3D matrix, Cern.Colt.Matrix.DoubleAlgorithms.DoubleMatrix2DComparator c)
        {
            int[] sliceIndexes = new int[matrix.Slices]; // indexes to reorder instead of matrix itself
            for (int i = sliceIndexes.Length; --i >= 0;)
            {
                sliceIndexes[i] = i;
            }

            DoubleMatrix2D[] views = new DoubleMatrix2D[matrix.Slices]; // precompute views for speed
            for (int i = views.Length; --i >= 0;)
            {
                views[i] = matrix.ViewSlice(i);
            }

            IntComparator comp = new IntComparator((a, b) => { return(c(views[a], views[b])); });


            RunSort(sliceIndexes, 0, sliceIndexes.Length, comp);

            // view the matrix according to the reordered slice indexes
            // take all rows and columns in the original order
            return(matrix.ViewSelection(sliceIndexes, null, null));
        }