Macaulay2 Engine
Loading...
Searching...
No Matches
◆
computeLU()
[1/5]
void
DMatLUinPlace
<
M2::ARingCC
>::computeLU
(
)
inline
private
Definition at line
367
of file
dmat-lu-inplace.hpp
.
368
{
369
if
(
mIsDone
)
return
;
370
371
// std::cout << "computing LU decomposition ARingCC" << std::endl;
372
int
rows
=
static_cast<
int
>
(
mLU
.numRows());
373
int
cols
=
static_cast<
int
>
(
mLU
.numColumns());
374
int
info
;
375
int
min
= (
rows
<=
cols
) ?
rows
:
cols
;
376
377
if
(
min
== 0)
378
return
;
379
380
int
*
perm
=
new
int
[
min
];
381
auto
copyA
=
make_lapack_array
(
mLU
);
382
383
zgetrf_
(&
rows
, &
cols
,
copyA
.data(), &
rows
,
perm
, &
info
);
384
385
if
(
info
< 0)
386
{
387
delete
[]
perm
;
388
throw
exc::engine_error
(
"argument passed to zgetrf had an illegal value"
);
389
}
390
391
// Now copy back to row major order
392
fill_from_lapack_array
(
copyA
,
mLU
);
393
394
// Now place the correct permutation into mPerm
395
for
(
int
i
= 0;
i
<
min
;
i
++)
396
{
397
int
thisloc
=
perm
[
i
] - 1;
398
if
(
i
!=
thisloc
)
399
{
400
mSign
=
not
mSign
;
401
size_t
tmp
=
mPerm
[
thisloc
];
402
mPerm
[
thisloc
] =
mPerm
[
i
];
403
mPerm
[
i
] =
tmp
;
404
}
405
}
406
407
LUUtil<RingType>::computePivotColumns
(
mLU
,
mPivotColumns
);
408
mIsDone
=
true
;
409
410
delete
[]
perm
;
411
}
DMatLUinPlace::mSign
bool mSign
Definition
dmat-lu-inplace.hpp:117
DMatLUinPlace::mLU
Mat mLU
Definition
dmat-lu-inplace.hpp:115
DMatLUinPlace::mPivotColumns
std::vector< size_t > mPivotColumns
Definition
dmat-lu-inplace.hpp:119
DMatLUinPlace::mPerm
std::vector< size_t > mPerm
Definition
dmat-lu-inplace.hpp:116
DMatLUinPlace::mIsDone
bool mIsDone
Definition
dmat-lu-inplace.hpp:118
DMatLUinPlace
Definition
dmat-lu-inplace.hpp:86
LUUtil::computePivotColumns
static void computePivotColumns(const Mat &LU, std::vector< size_t > &result_columns)
Definition
dmat-lu-inplace.hpp:440
make_lapack_array
std::vector< double > make_lapack_array(const DMatRR &mat)
Definition
lapack.cpp:20
fill_from_lapack_array
void fill_from_lapack_array(const std::vector< double > &doubles, DMatRR &mat)
Definition
lapack.cpp:45
zgetrf_
int zgetrf_(int *rows, int *cols, double *M, int *ld, int *ipiv, int *info)
DMatLUinPlace
Generated on
for Macaulay2 Engine by
1.15.0