inline int solve (int sys, int n, int const* Ap, int const* Ai, traits::complex_d const* Ax, traits::complex_d* X, traits::complex_d const* B, void *Numeric, double const* Control, double* Info) { int nnz = Ap[n]; bindings::detail::array<double> Axr (nnz); if (!Axr.valid()) return UMFPACK_ERROR_out_of_memory; bindings::detail::array<double> Axi (nnz); if (!Axi.valid()) return UMFPACK_ERROR_out_of_memory; traits::detail::disentangle (Ax, Ax+nnz, Axr.storage(), Axi.storage()); bindings::detail::array<double> Br (n); if (!Br.valid()) return UMFPACK_ERROR_out_of_memory; bindings::detail::array<double> Bi (n); if (!Bi.valid()) return UMFPACK_ERROR_out_of_memory; traits::detail::disentangle (B, B+n, Br.storage(), Bi.storage()); bindings::detail::array<double> Xr (n); if (!Xr.valid()) return UMFPACK_ERROR_out_of_memory; bindings::detail::array<double> Xi (n); if (!Xi.valid()) return UMFPACK_ERROR_out_of_memory; int status = umfpack_zi_solve (sys, Ap, Ai, Axr.storage(), Axi.storage(), Xr.storage(), Xi.storage(), Br.storage(), Bi.storage(), Numeric, Control, Info); if (status != UMFPACK_OK) return status; traits::detail::interlace (Xr.storage(), Xr.storage() + n, Xi.storage(), X); return status; }
//construction of a matrice according to a variable vector mat Vect::const_matrix(vector<int> vecteur) { mat Xr(Data.begin(), Data.nrow(), Data.ncol(), false); mat M = zeros<mat>(Data.nrow(), vecteur.size()); for(int i = 0; i < (int)vecteur.size(); ++i) M.col(i) = Xr.col(vecteur[i] - 1); return M; }//end Vect::const_matrix
void Foam::RBD::joints::Ra::jcalc ( joint::XSvc& J, const scalarField& q, const scalarField& w, const scalarField& qDot ) const { J.X = Xr(S_[0].w(), q[qIndex_]); J.S1 = S_[0]; J.v = S_[0]*qDot[qIndex_]; J.c = Zero; }
inline int report_vector (int n, traits::complex_d const* X, double const* Control) { #if 0 // see UMFPACK v 4.1 User Guide bindings::detail::array<double> Xr (n); if (!Xr.valid()) return UMFPACK_ERROR_out_of_memory; bindings::detail::array<double> Xi (n); if (!Xi.valid()) return UMFPACK_ERROR_out_of_memory; traits::detail::disentangle (X, X+n, Xr.storage(), Xi.storage()); return umfpack_zi_report_vector (n, Xr.storage(), Xi.storage(), Control); #endif return umfpack_zi_report_vector (n, reinterpret_cast<double const*> (X), reinterpret_cast<double const*> (0), Control); }
dvec CanteraGas::calculateReactantMixture(const std::string& fuel, const std::string& oxidizer, double equivalenceRatio) { size_t mC = thermo.elementIndex("C"); size_t mO = thermo.elementIndex("O"); size_t mH = thermo.elementIndex("H"); double Cf(0), Hf(0), Of(0); // moles of C/H/O in fuel double Co(0), Ho(0), Oo(0); // moles of C/H/O in oxidizer dvec Xf(nSpec), Xo(nSpec), Xr(nSpec); thermo.setState_TPX(300.0, pressure, fuel); getMoleFractions(Xf); thermo.setState_TPX(300.0, pressure, oxidizer); getMoleFractions(Xo); dvec a(thermo.nElements()); for (size_t k=0; k<nSpec; k++) { thermo.getAtoms(k, &a[0]); if (mC != npos) { Cf += a[mC]*Xf[k]; Co += a[mC]*Xo[k]; } if (mH != npos) { Hf += a[mH]*Xf[k]; Ho += a[mH]*Xo[k]; } if (mO != npos) { Of += a[mO]*Xf[k]; Oo += a[mO]*Xo[k]; } } double stoichAirFuelRatio = -(Of-2*Cf-Hf/2)/(Oo-2*Co-Ho/2); Xr = Xf * equivalenceRatio + stoichAirFuelRatio * Xo; Xr /= Xr.sum(); return Xr; }
inline int scale (int n, traits::complex_d* X, traits::complex_d const* B, void* Numeric) { bindings::detail::array<double> Br (n); if (!Br.valid()) return UMFPACK_ERROR_out_of_memory; bindings::detail::array<double> Bi (n); if (!Bi.valid()) return UMFPACK_ERROR_out_of_memory; traits::detail::disentangle (B, B+n, Br.storage(), Bi.storage()); bindings::detail::array<double> Xr (n); if (!Xr.valid()) return UMFPACK_ERROR_out_of_memory; bindings::detail::array<double> Xi (n); if (!Xi.valid()) return UMFPACK_ERROR_out_of_memory; int status = umfpack_zi_scale (Xr.storage(), Xi.storage(), Br.storage(), Bi.storage(), Numeric); if (status != UMFPACK_OK) return status; traits::detail::interlace (Xr.storage(), Xr.storage() + n, Xi.storage(), X); return status; }