Esempio n. 1
0
        public static SafeMatrix SolveLinearSystem(SafeMatrix A, SafeMatrix X)
        {
            double[] a = A.GetElements();
            double[] x = X.GetElements();
            double[] y = new double[A.ColumnCount * X.ColumnCount];

            SolveLinearSystem(a, A.RowCount, A.ColumnCount, x, X.RowCount, X.ColumnCount, y);

            SafeMatrix rv = new SafeMatrix(X.RowCount, X.ColumnCount);
            rv.SetElements(y);

            return rv;
        }
Esempio n. 2
0
        /// <summary>
        /// Warning: This method is not thread safe!
        /// </summary>
        public static SafeMatrix SolveLinearSystemFast(SafeMatrix A, SafeMatrix X)
        {
            if (A.RowCount > 35 * 35)
                throw new InvalidOperationException("Not a PSF fitting linear system.");

            if (s_NumVariables != A.ColumnCount)
            {
                LinearSystemFastInitialiseSolution(A.ColumnCount, 35 * 35);
                s_NumVariables = A.ColumnCount;
            }

            double[] a = A.GetElements();
            double[] x = X.GetElements();
            double[] y = new double[A.ColumnCount * X.ColumnCount];

            SolveLinearSystemFast(a, x, A.RowCount, y);

            SafeMatrix rv = new SafeMatrix(X.RowCount, X.ColumnCount);
            rv.SetElements(y);

            return rv;
        }