1 #ifndef MONTJOIE_FILE_TINY_MATRIX_INLINE_CXX
3 #include "TinyMatrix.hxx"
5 #include "TinyMatrixExpressionInline.cxx"
16 template<
class T,
int m,
int n>
24 template<
class T,
int m,
int n>
32 template<
class T,
int m,
int n>
40 template<
class T,
int m,
int n>
template<
class T0>
49 template<
class T,
int m,
int n>
template<
class E>
58 template<
class T,
int m,
int n>
66 template<
class T,
int m,
int n>
74 template<
class T,
int m,
int n>
82 template<
class T,
int m,
int n>
90 template<
class T,
int m,
int n>
template<
class T1>
100 template<
class T,
int m,
int n>
template<
class T1,
class E>
110 template<
class T,
int m,
int n>
template<
class T1,
class E>
120 template<
class T,
int m,
int n>
129 template<
class T,
int m,
int n>
template<
class T0,
class E>
139 template<
class T,
int m,
int n>
143 #ifdef SELDON_CHECK_BOUNDS
144 CheckBounds(a, b, m, n,
"TinyMatrix");
147 return this->data_[a*n+b];
152 template<
class T,
int m,
int n>
156 #ifdef SELDON_CHECK_BOUNDS
157 CheckBounds(a, b, m, n,
"TinyMatrix");
160 return this->data_[a*n+b];
165 template<
class T,
int m,
int n>
173 template<
class T,
int m,
int n>
177 #ifdef SELDON_CHECK_BOUNDS
179 throw WrongDim(
"TinyMatrix::SetIdentity()",
180 "The number of rows should be equal to the number of columns");
188 template<
class T,
int m,
int n>
template<
class T0>
192 #ifdef SELDON_CHECK_BOUNDS
194 throw WrongDim(
"TinyMatrix::SetDiagonal(alpha)",
195 "The number of rows should be equal to the number of columns");
203 template<
class T,
int m,
int n>
211 template<
class T,
int m,
int n>
219 template<
class T,
int m,
int n>
template<
class T0>
227 template<
class T,
int m,
int n>
235 template<
class T,
int m,
int n>
238 ofstream out(file_name.data());
245 template<
class T,
int m,
int n>
249 out.write(
reinterpret_cast<char*
>(&itmp),
sizeof(
int));
251 out.write(
reinterpret_cast<char*
>(&itmp),
sizeof(
int));
263 template<
int i,
int j,
int k>
template<
class T,
int m>
267 A(j, k-1) += val*A(i, k-1);
273 template<
int j,
int k,
int m>
template<
class T,
int p>
277 vloc -= A(k, m-1)*A(m-1, j);
288 template<
int p,
int q>
template<
int m,
int n,
class T0,
class T1>
292 A(q-1, p-1) = x(q-1);
298 template<
int p,
int q>
template<
int m,
int n,
class T,
class E>
302 out << A(m-p, n-q) <<
" ";
308 template<
int p,
int q>
template<
int m,
int n,
class T,
class Prop>
312 out.write(
reinterpret_cast<const char*
>(&A(m-p, n-q)),
sizeof(T));
318 template<
int p,
int q>
template<
int m,
int n,
class T,
class E1,
class E2>
331 template<
int i,
int j>
template<
int m,
int n,
class T0,
class E0,
332 class T1,
class E1,
class T2>
337 val += A(i-1, j)*x(j);
343 template<
int p,
int q>
344 template<
int m,
int n,
int k,
class T0,
class E0,
345 class T1,
class E1,
class T2,
class Prop2>
361 template<
int p,
int q>
362 template<
int m,
int n,
class T0,
class T1,
class E1,
class T2,
class E2,
class T3>
367 A(p-1, q-1) += alpha*x(p-1)*y(q-1);
373 template<
int p,
int q>
374 template<
int m,
int n,
class T1,
class E1,
class T2,
class E2,
class T3>
379 A(p-1, q-1) = x(p-1)*y(q-1);
385 template<
int p,
int q>
386 template<
int m,
class T0,
class T1,
class E1,
class T3>
391 A(p-1, q-1) += alpha*x(p-1)*x(q-1);
397 template<
int p,
int q>
398 template<
int m,
class T1,
class E1,
class T3>
403 A(p-1, q-1) = x(p-1)*x(q-1);
409 template<
int i,
int j>
template<
class T,
int m>
413 if (abs(A(j, i)) > abs(val))
424 template<
int i,
int j>
template<
class T,
int m>
429 A(i, j-1) = A(i2, j-1);
436 template<
int i,
int j>
template<
class T,
int m>
441 A(j-1, i) = A(j-1, i2);
448 template<
int i,
int j>
template<
class T,
int m>
458 template<
int i,
int j>
template<
class T,
int m>
476 template<
int i,
int j1>
template<
class T,
int m>
482 val = -A(i, m - 1 - j1 + i + 1);
487 A(i, m - 1 - j1 + i + 1) = val*A(m - 1 - j1 + i + 1, m - 1 - j1 + i + 1);
493 template<
int j,
int k>
template<
class T,
int m>
497 val -= A(k-1, j)*A(k-1, j);
503 template<
int j,
int k>
template<
class T,
int m>
510 A(j, m-k) = vloc*invVal;
516 template<
int i,
int k>
template<
class T,
class T2,
int m>
522 x(i+k) -= A(i, i+k)*x(i);
528 template<
int i,
int k>
template<
class T,
class T2,
int m>
534 val -= A(i, i+k)*x(i+k);
540 template<
int i,
int k>
template<
class T,
class T2,
int m>
546 x(i+k) += A(i, i+k)*x(i);
552 template<
int i,
int k>
template<
class T,
class T2,
int m>
558 val += A(i, i+k)*x(i+k);
569 template<
int p>
template<
int m,
int n,
class T,
class Prop>
572 FillZero(A.data_[p-1]);
578 template<
int p>
template<
int m,
int n,
class T0,
class T1>
588 template<
int k>
template<
int m,
int n,
class T0,
589 class Prop,
class T1>
593 A.data_[k-1] *= alpha;
599 template<
int p>
template<
int m,
int n,
class T1,
class E,
class T0,
class Prop>
611 template<
int p>
template<
int m,
int n,
class T1,
class E,
class T0,
class Prop>
623 template<
int p>
template<
int m,
int n,
class T1,
class E,
class T0,
class Prop>
635 template<
int p>
template<
int m,
int n,
class T,
class Prop>
646 template<
int p>
template<
int m,
int n,
class T,
class Prop,
class T0>
659 template<
int p>
template<
int m,
int n,
class T,
class Prop>
668 template<
int p>
template<
int m,
int n,
class T,
class Prop>
677 template<
int p>
template<
int m,
int n,
class T,
class Prop,
class T0>
686 template<
int p>
template<
int m,
int n,
class Prop,
class T>
689 if (!IsComplexZero(A.data_[p-1]))
697 template<
int p>
template<
int m,
int n,
class T,
class E>
708 template<
int p>
template<
int m,
int n,
class T,
class Prop>
717 template<
int p>
template<
int m,
int n,
class T,
class E1,
class E2>
730 template<
int i>
template<
int m,
int n,
class T0,
class E0,
731 class T1,
class E1,
class T2>
736 y(i-1) = A(i-1, 0)*x(0);
743 template<
int i>
template<
int m,
int n,
class T0,
class E0,
744 class T1,
class E1,
class T2>
749 y(i-1) += A(i-1, 0)*x(0);
756 template<
int i>
template<
int m,
int n,
class T0,
class E0,
757 class T1,
class E1,
class T2,
class T3>
762 T2 val = A(i-1, 0)*x(0);
770 template<
int p>
template<
int m,
int n,
int k,
class T0,
class E0,
771 class T1,
class E1,
class T2,
class Prop2>
786 template<
int p>
template<
int m,
int n,
class T0,
class T1,
class E1,
787 class T2,
class E2,
class T3>
798 template<
int p>
template<
int m,
int n,
class T1,
class E1,
799 class T2,
class E2,
class T3>
810 template<
int p>
template<
int m,
class T0,
class T1,
class E1,
class T3>
821 template<
int p>
template<
int m,
class T1,
class E1,
class T3>
832 template<
int p>
template<
int m,
int n,
class T1,
class E1>
842 template<
int p>
template<
int m,
int n,
class T0,
class E0,
class T1>
852 template<
int p>
template<
int m,
int n,
class T1,
class E1,
class Prop>
862 template<
int p>
template<
int m,
int n,
class T1,
class E1,
class Prop>
872 template<
int p>
template<
int m,
int n,
class T,
class Prop,
class T0>
875 amax = max(amax, abs(A.data_[p-1]));
881 template<
int i1>
template<
class T,
int m>
887 int jmax = m -1 - i1; T val = A(m -1 - i1, m -1 - i1), coef;
889 pivot(m -1 - i1) = jmax;
892 if (m -1 - i1 != jmax)
896 T one; SetComplexOne(one);
897 coef = one/A(m -1 - i1, m -1 - i1);
902 A(m -1 - i1, m -1 - i1) = coef;
909 template<
int i1>
template<
class T,
int m>
920 template<
int i>
template<
class T,
int m>
925 if (pivot(i-1) != i-1)
933 template<
int j>
template<
class T,
int m>
941 T one; SetComplexOne(one);
942 T invVal = one / val, vloc;
951 template<
int i>
template<
class T,
class T2,
int m>
956 x(m-i) /= A(m-i, m-i);
963 template<
int i>
template<
class T,
class T2,
int m>
971 x(i-1) = val / A(i-1, i-1);
977 template<
int i>
template<
class T,
class T2,
int m>
984 x(i-1) *= A(i-1, i-1);
990 template<
int i>
template<
class T,
class T2,
int m>
995 T val = x(m-i)*A(m-i, m-i);
1008 template<
class T,
int m>
1016 template<
class T,
int m>
1024 template<
class T,
int m>
1032 template<
class T,
int m>
template<
class E>
1041 template<
class T,
int m>
1049 template<
class T,
int m>
1057 template<
class T,
int m>
1065 template<
class T,
int m>
1073 template<
class T,
int m>
template<
class T1>
1084 template<
class T,
int m>
template<
class T1,
class E>
1094 template<
class T,
int m>
template<
class T1,
class E>
1104 template<
class T,
int m>
1114 template<
class T,
int m>
template<
class T0,
class E>
1124 template<
class T,
int m>
1128 #ifdef SELDON_CHECK_BOUNDS
1129 CheckBounds(i, j, m, m,
"TinyMatrix");
1132 return this->data_[j > i ? i*m - (i*(i+1))/2 + j: j*m - (j*(j+1))/2 + i];
1137 template<
class T,
int m>
1141 #ifdef SELDON_CHECK_BOUNDS
1142 CheckBounds(i, j, m, m,
"TinyMatrix");
1145 return this->data_[j > i ? i*m - (i*(i+1))/2 + j: j*m - (j*(j+1))/2 + i ];
1150 template<
class T,
int m>
1158 template<
class T,
int m>
1166 template<
class T,
int m>
template<
class T0>
1174 template<
class T,
int m>
1182 template<
class T,
int m>
1190 template<
class T,
int m>
template<
class T0>
1198 template<
class T,
int m>
1206 template<
class T,
int m>
1209 ofstream out(file_name.data());
1210 out.precision(cout.precision());
1217 template<
class T,
int m>
1220 ofstream out(file_name.data());
1227 template<
class T,
int m>
1231 out.write(
reinterpret_cast<char*
>(&itmp),
sizeof(
int));
1232 out.write(
reinterpret_cast<char*
>(&itmp),
sizeof(
int));
1244 template<
class T,
int m,
int n,
class E1,
class E2>
1253 template<
class T,
int m,
int n,
class E1,
class E2>
1262 template <
class T,
int m,
int n,
class E>
1276 template<
class T,
int m,
int n,
class E,
class T1,
class E1>
inline TinyVector<T1, m>
1288 template<
class T,
int m,
int n,
class E,
class T1,
int k,
class E1>
1289 inline TinyMatrix<T, General, m, k>
1301 template<
class T0,
class E0,
class T1,
class E1,
class T2,
int m,
int n>
1310 template<
class T1,
class E1,
class T2,
class E2,
class T3,
int m,
int n>
1319 template<
class T0,
class T1,
class E1,
class T2,
class E2,
class T3,
int m,
int n>
1328 template<
class T0,
class E0,
class T1,
class E1,
class T2,
int m,
int n>
1337 template<
class T0,
class E0,
class T1,
class E1,
class T2,
int m,
int n>
1347 template<
int m,
int n,
class T0,
class T1,
class E1,
class T2,
class E2,
class T3>
1357 template<
int m,
int n,
class T1,
class E1,
class T2,
class E2,
class T3>
1367 template<
int m,
class T0,
class T1,
class E1,
class T3>
1376 template<
int m,
class T1,
class E1,
class T3>
1385 template<
int m,
int n,
class T1,
class E1>
1393 template<
int m,
int n,
class T0,
class E0,
class T1>
1401 template<
int m,
int n,
class T1,
class E1,
class Prop>
1409 template<
int m,
int n,
class T1,
class E1,
class Prop>
1422 template<
class T,
int m,
int n,
class E,
class Prop>
1430 template<
class T0,
class E0,
class T1,
class E1,
1431 class T2,
class Prop2,
int m,
int n>
1441 template<
class T1,
class E1,
class T2,
1442 class Prop2,
int m,
int n>
1451 template<
class T0,
class E0,
class T1,
class Prop1,
int m,
int n>
1459 template<
class T0,
class T1,
class Prop,
int m,
int n>
1467 template<
class T0,
class E0,
class T1,
class E1,
1468 class T2,
class Prop2,
int m,
int n,
int k>
1478 template<
class T0,
class E0,
class T1,
class E1,
1479 class T2,
class Prop2,
int m,
int n,
int k>
1489 template<
class T3,
class T0,
class E0,
class T1,
class E1,
1490 class T2,
class Prop2,
class T4,
int m,
int n,
int k>
1498 C = beta*C + alpha*D;
1503 template<
class T,
int m,
int n,
class E>
1512 template<
class T,
int m>
1520 template<
class T,
class Prop,
int m,
int n>
inline
1521 typename ClassComplexType<T>::Treal
MaxAbs(
const TinyMatrix<T, Prop, m, n>& A)
1523 typename ClassComplexType<T>::Treal amax(0);
1524 TinyMatrixLoop<TinyMatrix<T, Prop, m, n>::size_>::GetMaxAbs(A, amax);
1535 template<
class T,
class Prop>
1547 T one; SetComplexOne(one);
1548 B(0,0) = one/A(0, 0);
1557 T one; SetComplexOne(one);
1558 B(0,0) = one/A(0, 0);
1566 T one; SetComplexOne(one);
1567 B(0,0) = one/B(0, 0);
1575 T one; SetComplexOne(one);
1576 B(0,0) = one/B(0, 0);
1582 template<
class T0,
class T1>
1591 template<
class T0,
class T1>
1604 template<
class T,
class Prop>
1607 return A(0,0)*A(1,1) - A(0,1)*A(1,0);
1613 template<
class T0,
class T1>
1617 P(0, 0) = n(1)*n(1);
1618 P(0, 1) = -n(0)*n(1);
1619 P(1, 1) = n(0)*n(0);
1625 template<
class T0,
class T1>
1628 P(0, 0) = n(0)*n(0);
1629 P(0, 1) = n(0)*n(1);
1630 P(1, 1) = n(1)*n(1);
1636 template<
class T0,
class T1>
1639 P(0, 0) = n(0)*n(0);
1640 P(0, 1) = n(0)*n(1);
1641 P(1, 1) = n(1)*n(1);
1652 template<
class T0,
class T1,
int m>
1656 T0 one; SetComplexOne(one);
1658 Rank1Update(-one, n, P);
1663 template<
class T0,
class T1,
int m>
1671 template<
class T,
class Prop,
int m,
int n>
1672 inline void FillZero(TinyMatrix<T, Prop, m, n>& X)
1679 template<
class T,
int m,
int n>
1684 for (
int p = 0; p < n ; p ++)
1686 GetCol(A, p, vectA);
1687 GetCol(B, p, vectB);
1688 res(p) += DotProd(vectA, vectB);
1694 #define MONTJOIE_FILE_TINY_MATRIX_INLINE_CXX
static void AddRow(TinyMatrix< T, General, m, m > &A, const T &val)
A(j, :) += val*A(i, :)
Class storing small matrices whose number of rows and columns is known at compilation time.
static bool IsZero(const TinyMatrix< T, Prop, m, n > &A)
returns true if the matrix is null
static void SwapColumn(TinyMatrix< T, General, m, m > &A, int i2, T &val)
swapping columns i and i2 (for pivoting)
static void DiffCopy(const TinyMatrixExpression< T1, m, n, E > &x, TinyMatrix< T0, Prop, m, n > &y)
y -= x
static void Mlt(const TinyMatrixExpression< T0, m, n, E0 > &A, const TinyVectorExpression< T1, n, E1 > &x, T2 &y)
y = A*x
bool operator==(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns true if *this == u
static void MltAdd(const TinyMatrixExpression< T0, m, n, E0 > &A, const TinyVectorExpression< T1, n, E1 > &x, TinyVector< T2, m > &y)
y = y + A*x
void Rank1Matrix(const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = x y^T.
empty class overloaded for general and symmetric matrices
static void Write(ostream &out, const TinyMatrix< T, Prop, m, n > &A)
writes matrix A in binary format
static void GetDiagonalCholesky(TinyMatrix< T, Symmetric, m, m > &A, T &val)
Loop val -= A(k, j)*A(k, j) with k between 0 and j-1.
Expression between vectors.
static void FillRand(TinyMatrix< T, Prop, m, n > &A)
sets randomly all the elements of A
static void SwapRow(TinyMatrix< T, General, m, m > &A, int i2, T &val)
swapping rows i and i2 (for pivoting)
static void SolveCholesky(const class_SeldonNoTrans &trans, const TinyMatrix< T, Symmetric, m, m > &A, TinyVector< T2, m > &x)
double loop for Cholesky resolution and NoTranspose
static void GetMaximumColumn(TinyMatrix< T, General, m, m > &A, int &jmax, T &val)
returns index jmax for which |A(i, j)| is maximal
static void Write(ostream &out, const TinyMatrix< T, Prop, m, n > &A)
writes matrix A in binary format
static void SetIdentity(TinyMatrix< T, Prop, m, n > &A)
sets matrix to the identity matrix
static void WriteText(ostream &out, const TinyMatrixExpression< T, m, n, E > &A)
writes matrix A in ascii format
static void Copy(const TinyMatrixExpression< T1, m, n, E > &x, TinyMatrix< T0, Prop, m, n > &y)
y = x
static void GetMaxAbs(const TinyMatrix< T, Prop, m, n > &A, T0 &amax)
computes the maximal element of matrix A
static void SetCol(const TinyVectorExpression< T1, m, E1 > &x, int k, TinyMatrix< T1, Prop, m, n > &A)
A(:, k) = x.
static void Init(const TinyVector< TinyVector< T0, m >, n > &x, TinyMatrix< T1, General, m, n > &A)
Conversion from vector of vectors to matrix.
static void Fill(TinyMatrix< T, Prop, m, n > &A)
sets matrix to [0, 1, 2; 3, 4, 5 ...]
vector with real/complex components
class for simple loops for matrix operations
static void ModifyUpperCholesky(TinyMatrix< T, Symmetric, m, m > &A, T &invVal, T &vloc)
Loop with k between j+1 and n-1.
static void GetRow(const TinyMatrixExpression< T0, m, n, E0 > &A, int k, TinyVector< T1, n > &x)
x = A(k, :)
static void PerformSolve(TinyMatrix< T, General, m, m > &A, T &val)
solving by upper matrix
static void SolveCholesky(const class_SeldonNoTrans &trans, const TinyMatrix< T, Symmetric, m, m > &A, TinyVector< T2, m > &x)
simple loop for Cholesky resolution and NoTranspose
static void Init(const TinyVector< T0, m > &x, TinyMatrix< T1, General, m, n > &A)
Conversion from vector of vectors to matrix.
static void Rank1Update(const T0 &alpha, const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = A + alpha * x y^T.
const TinyMatrixTranspose< T, m, n, E > transpose(const TinyMatrixExpression< T, n, m, E > &u)
returns transpose(u)
static void MltRow(TinyMatrix< T, General, m, m > &A, const T &coef)
A(i, :) = A(i, :)*coef.
static void PivotGauss(TinyMatrix< T, General, m, m > &A, TinyVector< int, m > &pivot)
step i1 of Gauss elimination
static void SetRow(const TinyVectorExpression< T1, n, E1 > &x, int k, TinyMatrix< T1, Prop, m, n > &A)
A(k, :) = x.
static void PermuteColumn(TinyMatrix< T, General, m, m > &A, const TinyVector< int, m > &pivot)
swapping columns for Gauss pivoting
class storing tiny small matrices
static void AddCopy(const TinyMatrixExpression< T1, m, n, E > &x, TinyMatrix< T0, Prop, m, n > &y)
y += x
static void WriteText(ostream &out, const TinyMatrixExpression< T, m, n, E > &A)
writes matrix A in ascii format
static void GetCol(const TinyMatrixExpression< T1, m, n, E1 > &A, int k, TinyVector< T1, m > &x)
x = A(:, k)
class for double loop in matrix functions
void MltTrans(const TinyMatrixExpression< T0, m, n, E0 > &A, const TinyVectorExpression< T1, m, E1 > &x, TinyVector< T2, n > &y)
y = A^t * x
Expression between vectors.
static void GetCholesky(TinyMatrix< T, Symmetric, m, m > &A)
main loop for Cholesky factorisation
static void Rank1Update(const T0 &alpha, const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = A + alpha * x y^T.
void Transpose(Matrix< T, Prop, Storage, Allocator > &A)
Matrix transposition.
bool operator!=(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns true if *this != u
static void MltCholesky(const class_SeldonTrans &trans, const TinyMatrix< T, Symmetric, m, m > &A, TinyVector< T2, m > &x, T2 &val)
double loop for Cholesky multiplication and Transpose
static void MltScal(const T0 &alpha, TinyMatrix< T1, Prop, m, n > &A)
A = alpha*A.
static void MltCholesky(const class_SeldonTrans &trans, const TinyMatrix< T, Symmetric, m, m > &A, TinyVector< T2, m > &x)
simple loop for Cholesky multiplication and Transpose
static void Mlt(const TinyMatrixExpression< T0, m, n, E0 > &A, const TinyVectorExpression< T1, n, E1 > &x, TinyVector< T2, m > &y)
y = A*x
ClassComplexType< T >::Treal MaxAbs(const Matrix< T, Prop, Storage, Allocator > &A)
Returns the maximum (in absolute value) of a matrix.
static void SetDiagonal(TinyMatrix< T, Prop, m, n > &A, const T0 &diag)
sets matrix to the identity matrix multiplied by a coefficient alpha
static void Rank1Matrix(const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = x y^T.
static bool IsEqual(const TinyMatrixExpression< T, m, n, E1 > &A, const TinyMatrixExpression< T, m, n, E2 > &B)
returns true if A == B
TinyVector< T1, m > dot(const TinyMatrixExpression< T, m, n, E > &A, const TinyVectorExpression< T1, n, E1 > &x)
returns A*x
ostream & operator<<(ostream &out, const Array< T, N, Allocator > &A)
operator<< overloaded for a 3D array.
void DotProdCol(const TinyMatrix< T, General, m, n > &A, const TinyMatrix< T, General, m, n > &B, TinyVector< T, n > &res)
res = A . B, where the scalar product is performed between columns of A and B
class for triple loop in matrix functions
static void Rank1Matrix(const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = x y^T.
static void PerformElimination(TinyMatrix< T, General, m, m > &A, const T &coef, T &val)
performs Lj = Lj - a_ji/aii Li to eliminate element a_ij
void SetComplexReal(int n, std::complex< T > &number)
Sets a complex number to (n, 0).
static void SolveUpper(TinyMatrix< T, General, m, m > &A)
solving by upper matrix