# Calculate the rank of a 10\*10 matrix to find whether it is rank deficient

**URL:** <https://community.freefem.org/t/calculate-the-rank-of-a-10-10-matrix-to-find-whether-it-is-rank-deficient/4144>\
**Category:** General Discussion\
**Created:** [December 1, 2025, 12:27pm UTC](https://community.freefem.org/t/calculate-the-rank-of-a-10-10-matrix-to-find-whether-it-is-rank-deficient/4144 "2025-12-01T12:27:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MatrixVector](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@MatrixVector](https://community.freefem.org/u/MatrixVector)\
**Post date:** [December 1, 2025, 12:27pm UTC](https://community.freefem.org/t/calculate-the-rank-of-a-10-10-matrix-to-find-whether-it-is-rank-deficient/4144/1 "2025-12-01T12:27:32Z")

</div>

Is it possible using FreeFem++ to calculate the rank of a 10\*10 matrix? I’m dealing with a least-square fitting problem in 3D, and a piece of code is about:

check whether the rank of a 10\*10 matrix is equal to 10. If so, then using the least-square fitting of polynomial of order 2; otherwise the matrix is rank deficient, then using the fitting of a polynomial of order 1.

Besides, the least-square fitting problem is solved by sparsesolver/UMFPACK:

```cpp
matrix AtA = A' * A;

set(AtA, solver = UMFPACK);

real[int] rhs;

real[int] a = AtA^-1 * rhs;

```

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [December 1, 2025, 1:48pm UTC](https://community.freefem.org/t/calculate-the-rank-of-a-10-10-matrix-to-find-whether-it-is-rank-deficient/4144/2 "2025-12-01T13:48:51Z")

</div>

Use LAPACK or SLEPc to compute the SVD of the matrix.
