Skip to content

Commit

Permalink
Restore dimension deduction in addFromArray with additional checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed Mar 28, 2024
1 parent 6439c42 commit c52d1be
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion expui/BiorthBasis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ namespace BasisClasses
int ldim = (lmax+1)*(lmax+2)/2;

// Allocate the coefficient storage
cf->store.resize((lmax+1)*(lmax+2)/2, nmax);
cf->store.resize((lmax+1)*(lmax+2)/2*nmax);

// Make the coefficient map
cf->coefs = std::make_shared<CoefClasses::SphStruct::coefType>
Expand Down Expand Up @@ -2302,6 +2302,32 @@ namespace BasisClasses
throw std::runtime_error(msg);
}

// Assume position arrays in rows by default
//
int rows = p.rows();
int cols = p.cols();

bool ambiguous = false;

if (cols==3 or cols==6) {
if (rows>cols or rows != 6 or rows != 3) PosVelRows = false;
else ambiguous = true;
}

if (rows==3 or rows==6) {
if (cols>rows or cols != 6 or cols != 3) PosVelRows = true;
else ambiguous = true;
}

if (ambiguous and myid==0) {
std::cout << "---- BiorthBasis::addFromArray: dimension deduction "
<< "is ambiguous. Assuming that ";
if (PosVelRows) std::cout << "positions are in rows" << std::endl;
else std::cout << "positions are in columns" << std::endl;
std::cout << "---- BiorthBasis::addFromArray: reset 'posvelrows' flag "
<< "if this assumption is wrong." << std::endl;
}

std::vector<double> p1(3), v1(3, 0);

if (PosVelRows) {
Expand Down

0 comments on commit c52d1be

Please sign in to comment.