internal Tuple <double[], double[]> FunctionApproximationControlPointsAndAuxiliaryKnots(int degree, double[] pointsX, double[] pointsY, double[] knots, int[] knotsIndexes) { Tuple <double[][], double[]> matrixAndAuxKnots = FunctionApproximationMatrix(pointsX, knots, knotsIndexes, degree); double[][] matrix = matrixAndAuxKnots.Item1; double[][] transposeMatrix = MathOperations.TransposeMatrix(matrix); double[][] transposeAndMatrixMultiplicationInversion = MathOperations.MatrixInvert(MathOperations.MultiplyMatrices(transposeMatrix, matrix)); double[][] YMatrix = ArrayMyUtils.ArrayToMatrix(pointsY); double[][] finalMatrix; double[] finalMatrixAsArray; List <double[][]> matrixList = new List <double[][]>(); matrixList.Add(transposeAndMatrixMultiplicationInversion); matrixList.Add(transposeMatrix); matrixList.Add(YMatrix); finalMatrix = MathOperations.MultiplyListOfMatrices(matrixList); try { finalMatrixAsArray = ArrayMyUtils.OneColumnMatrixToArray(finalMatrix); } catch (NumberOfMatrixColumnIsNotOneException) { System.Diagnostics.Debug.WriteLine("Matrix cannot be converted to an array because number of columns is not one"); return(null); } return(new Tuple <double[], double[]>(finalMatrixAsArray, matrixAndAuxKnots.Item2)); }