9 template <
unsigned int n,
class real>
15 for (
int icol = 0; icol < n; icol++) {
16 for (
int irow = 0; irow < n; irow++) {
17 scratch(icol,irow) = a(icol,irow);
27 for (
int idiag = 0; idiag < n; idiag++) {
29 real factor =
static_cast<real
>(1)/scratch(idiag,idiag);
30 for (
int icol = idiag; icol < n; icol++) {
31 scratch(idiag,icol) *= factor;
33 for (
int icol = 0; icol < n; icol++) {
34 inv(idiag,icol) *= factor;
36 for (
int irow = idiag+1; irow < n; irow++) {
37 real factor = scratch(irow,idiag);
38 for (
int icol = idiag; icol < n; icol++) {
39 scratch(irow,icol) -= factor * scratch(idiag,icol);
41 for (
int icol = 0; icol < n; icol++) {
42 inv (irow,icol) -= factor * inv (idiag,icol);
48 for (
int idiag = n-1; idiag >= 1; idiag--) {
49 for (
int irow = 0; irow < idiag; irow++) {
50 real factor = scratch(irow,idiag);
51 for (
int icol = irow+1; icol < n; icol++) {
52 scratch(irow,icol) -= factor * scratch(idiag,icol);
54 for (
int icol = 0; icol < n; icol++) {
55 inv (irow,icol) -= factor * inv (idiag,icol);
64 template <
int n,
class real>
70 for (
int icol = 0; icol < n; icol++) {
71 for (
int irow = 0; irow < n; irow++) {
72 scratch(icol+1,irow+1) = a(icol+1,irow+1);
74 inv(irow+1,icol+1) = 1;
76 inv(irow+1,icol+1) = 0;
82 for (
int idiag = 0; idiag < n; idiag++) {
84 real factor =
static_cast<real
>(1)/scratch(idiag+1,idiag+1);
85 for (
int icol = idiag; icol < n; icol++) {
86 scratch(idiag+1,icol+1) *= factor;
88 for (
int icol = 0; icol < n; icol++) {
89 inv(idiag+1,icol+1) *= factor;
91 for (
int irow = idiag+1; irow < n; irow++) {
92 real factor = scratch(irow+1,idiag+1);
93 for (
int icol = idiag; icol < n; icol++) {
94 scratch(irow+1,icol+1) -= factor * scratch(idiag+1,icol+1);
96 for (
int icol = 0; icol < n; icol++) {
97 inv (irow+1,icol+1) -= factor * inv (idiag+1,icol+1);
103 for (
int idiag = n-1; idiag >= 1; idiag--) {
104 for (
int irow = 0; irow < idiag; irow++) {
105 real factor = scratch(irow+1,idiag+1);
106 for (
int icol = irow+1; icol < n; icol++) {
107 scratch(irow+1,icol+1) -= factor * scratch(idiag+1,icol+1);
109 for (
int icol = 0; icol < n; icol++) {
110 inv (irow+1,icol+1) -= factor * inv (idiag+1,icol+1);