34 static constexpr char UPLO = UL;
42 pposv(
const IT rows,
const IT cols)
48 if(!this->ctx.is_valid())
return 0;
50 if(A.n_rows != A.n_cols || A.n_rows != B.n_rows)
return -1;
52 this->init_storage(A.n_rows);
54 this->ctx.scatter(A, this->ctx.desc_g(A.n_rows, A.n_cols), this->loc.a, this->loc.desc_a);
58 if constexpr(std::is_same_v<DT, double>) {
60 pdpotrf(&UPLO, &this->loc.n, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), &info);
62 else if constexpr(std::is_same_v<DT, float>) {
64 pspotrf(&UPLO, &this->loc.n, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), &info);
66 else if constexpr(std::is_same_v<DT, complex16>) {
68 pzpotrf(&UPLO, &this->loc.n, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), &info);
70 else if constexpr(std::is_same_v<DT, complex8>) {
72 pcpotrf(&UPLO, &this->loc.n, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.data(), &info);
76 if((info = this->ctx.amx(info)) != 0)
return info;
78 return solve(std::move(B));
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 pdpotrs(&UPLO, &this->loc.n, &B.n_cols, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.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 pspotrs(&UPLO, &this->loc.n, &B.n_cols, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.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 pzpotrs(&UPLO, &this->loc.n, &B.n_cols, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.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 pcpotrs(&UPLO, &this->loc.n, &B.n_cols, (E*)this->loc.a.data(), &this->ONE, &this->ONE, this->loc.desc_a.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);