{"record":{"id":"4d98e554db1ef5ce","repo":"TheAlgorithms/C-Sharp","slug":"please-use-a-n-n-1-matrix-with-length-0","errorCode":null,"errorMessage":"Please use a n*(n+1) matrix with Length > 0.","messagePattern":"Please use a n\\*\\(n\\+1\\) matrix with Length > 0\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Algorithms/Numeric/GaussJordanElimination.cs","lineNumber":24,"sourceCode":"public class GaussJordanElimination\n{\n    private int RowCount { get; set; }\n\n    /// <summary>\n    ///     Method to find a linear equation system using gaussian elimination.\n    /// </summary>\n    /// <param name=\"matrix\">The key matrix to solve via algorithm.</param>\n    /// <returns>\n    ///     whether the input matrix has a unique solution or not.\n    ///     and solves on the given matrix.\n    /// </returns>\n    public bool Solve(double[,] matrix)\n    {\n        RowCount = matrix.GetUpperBound(0) + 1;\n\n        if (!CanMatrixBeUsed(matrix))\n        {\n            throw new ArgumentException(\"Please use a n*(n+1) matrix with Length > 0.\");\n        }\n\n        var pivot = PivotMatrix(ref matrix);\n        if (!pivot)\n        {\n            return false;\n        }\n\n        Elimination(ref matrix);\n\n        return ElementaryReduction(ref matrix);\n    }\n\n    /// <summary>\n    ///     To make simple validation of the matrix to be used.\n    /// </summary>\n    /// <param name=\"matrix\">Multidimensional array matrix.</param>\n    /// <returns>","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/TheAlgorithms/C-Sharp/blob/96e2905cab7bc6b33ac0a34ee5bb82ddccbcbb6c/Algorithms/Numeric/GaussJordanElimination.cs#L6-L42","documentation":"Solve validates the matrix via CanMatrixBeUsed before solving; this ArgumentException fires when the matrix is not a non-empty n*(n+1) augmented matrix, the only shape a linear system solvable by Gauss-Jordan has.","triggerScenarios":"Thrown at Algorithms/Numeric/GaussJordanElimination.cs:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reshape the input to an n x (n+1) matrix: the n coefficients of each equation plus the right-hand-side constant in the last column, and at least 2 rows.","Ensure the matrix is non-empty (Length > 0) and element [i, n] holds the constant term of equation i before calling Solve."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"96e2905cab7bc6b33ac0a34ee5bb82ddccbcbb6c","analyzedAt":"2026-09-13T17:04:01.438Z","contentChangedAt":"2026-09-13T17:04:01.438Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}