40 pgesv(
const IT rows,
const IT cols)
46 if(!this->ctx.is_valid())
return 0;
48 if(A.n_rows != A.n_cols || A.n_rows != B.n_rows)
return -1;
50 this->init_storage(A.n_rows);
52 this->ctx.scatter(A, this->ctx.desc_g(A.n_rows, A.n_cols), this->loc.a, this->loc.desc_a);
56 if constexpr(std::is_same_v<DT, double>) {
58 pdgetrf(&this->loc.n, &this->loc.n, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), this->loc.ipiv.data(), &info);
60 else if constexpr(std::is_same_v<DT, float>) {
62 psgetrf(&this->loc.n, &this->loc.n, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), this->loc.ipiv.data(), &info);
64 else if constexpr(std::is_same_v<DT, complex16>) {
66 pzgetrf(&this->loc.n, &this->loc.n, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), this->loc.ipiv.data(), &info);
68 else if constexpr(std::is_same_v<DT, complex8>) {
70 pcgetrf(&this->loc.n, &this->loc.n, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), this->loc.ipiv.data(), &info);
74 if((info = this->ctx.amx(info)) != 0)
return info;
76 return solve(std::move(B));
80 static constexpr char TRANS =
'N';
82 if(B.n_rows != this->loc.n)
return -1;
84 if(!this->ctx.is_valid())
return 0;
86 this->loc.b.resize(this->loc.rows * this->ctx.cols(B.n_cols, this->loc.block));
88 const auto full_desc_b = this->ctx.desc_g(B.n_rows, B.n_cols);
89 const auto loc_desc_b = this->ctx.desc_l(B.n_rows, B.n_cols, this->loc.block, this->loc.rows);
91 this->ctx.scatter(B, full_desc_b, this->loc.b, loc_desc_b);
95 if constexpr(std::is_same_v<DT, double>) {
97 pdgetrs(&TRANS, &this->loc.n, &B.n_cols, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), this->loc.ipiv.data(), (E*)this->loc.b.data(), &this->ONE, &this->ONE, loc_desc_b.data(), &info);
99 else if constexpr(std::is_same_v<DT, float>) {
101 psgetrs(&TRANS, &this->loc.n, &B.n_cols, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), this->loc.ipiv.data(), (E*)this->loc.b.data(), &this->ONE, &this->ONE, loc_desc_b.data(), &info);
103 else if constexpr(std::is_same_v<DT, complex16>) {
105 pzgetrs(&TRANS, &this->loc.n, &B.n_cols, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), this->loc.ipiv.data(), (E*)this->loc.b.data(), &this->ONE, &this->ONE, loc_desc_b.data(), &info);
107 else if constexpr(std::is_same_v<DT, complex8>) {
109 pcgetrs(&TRANS, &this->loc.n, &B.n_cols, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), this->loc.ipiv.data(), (E*)this->loc.b.data(), &this->ONE, &this->ONE, loc_desc_b.data(), &info);
113 if((info = this->ctx.amx(info)) == 0) this->ctx.gather(this->loc.b, loc_desc_b, B, full_desc_b);