This commit is contained in:
Atgeirr Flø Rasmussen 2012-03-20 10:33:44 +01:00
commit d75e55a968
2 changed files with 66 additions and 15 deletions

View File

@ -47,7 +47,7 @@ along with OpenRS. If not, see <http://www.gnu.org/licenses/>.
namespace Opm {
namespace parameter {
/// ParameterGroup is a class that is used to provide run-time paramters.
/// ParameterGroup is a class that is used to provide run-time parameters.
/// The standard use of the class is to call create it with the
/// (int argc, char** argv) constructor (where the arguments are those
/// given by main). This parses the command line, where each token
@ -55,7 +55,7 @@ namespace Opm {
/// A) specifies a parameter (by a "param=value" token).
/// B) specifies a xml file to be read (by a "filename.xml" token).
/// C) specifies a param file to be read (by a "filename.param" token).
/// After the tokens are parsem they are stored in a tree structure
/// After the tokens are parsed they are stored in a tree structure
/// in the ParameterGroup object; it is worth mentioning that parameters
/// are inherited in this tree structure. Thus, if ``grid\_prefix'' is
/// given a value in the root node, this value will be visible in all

View File

@ -21,6 +21,26 @@
#include <iostream>
#include <vector>
namespace {
struct BandMatrixCoeff
{
BandMatrixCoeff(int N, int ku, int kl) : N_(N), ku_(ku), kl_(kl), nrow_(2*kl + ku + 1) {
}
// compute the position where to store the coefficient of a matrix A_{i,j} (i,j=0,...,N-1)
// in a array which is sent to the band matrix solver of LAPACK.
int operator ()(int i, int j) {
return kl_ + ku_ + i - j + j*nrow_;
}
const int ku_;
const int kl_;
const int nrow_;
const int N_;
};
} //end anonymous namespace
int main()
{
@ -43,11 +63,11 @@ int main()
}
//test of dgbsv_
const int kl = 1;
const int ku = 1;
const int nrowAB = 2*kl + ku + 1;
const int ldb = N;
const int ldab = nrowAB;
int kl = 1;
int ku = 1;
int nrowAB = 2*kl + ku + 1;
int ldb = N;
int ldab = nrowAB;
int ipiv;
std::vector<double> AB(nrowAB*N, 0.);
std::vector<double> BB(N, 0.);
@ -64,14 +84,7 @@ int main()
BB[2] = 2.6;
BB[3] = 0.6;
BB[4] = 2.7;
std::vector<double>::iterator it;
std::cout << "myvector contains:";
for ( it=AB.begin() ; it < AB.end(); it++ ) {
std::cout << " " << *it;
}
std::cout << std::endl;
dgbsv_(&N, &kl, &ku, &nrhs, &AB[0], &ldab, &ipiv, &BB[0], &ldb, &info);
if (info == 0) {
@ -82,5 +95,43 @@ int main()
} else {
std::cerr << "Something went wrong in dgbsv_()\n";
}
int NN = 3;
kl = 1;
ku = 1;
nrowAB = 2*kl + ku + 1;
ldb = NN;
ldab = nrowAB;
AB.assign(NN*nrowAB, 0.);
BB.assign(NN, 0.);
BandMatrixCoeff bmc(NN, ku, kl);
AB[bmc(0, 0)] = 1.;
AB[bmc(1, 0)] = 1.;
AB[bmc(0, 1)] = 1.;
AB[bmc(1, 1)] = 2.;
AB[bmc(2, 1)] = 2.;
AB[bmc(1, 2)] = 1.;
AB[bmc(2, 2)] = 4.;
BB[0] = 3.;
BB[1] = 8.;
BB[2] = 16.;
// std::vector<double>::iterator it;
// std::cout << "myvector contains:";
// for ( it=AB.begin() ; it < AB.end(); it++ ) {
// std::cout << " " << *it;
// }
// std::cout << std::endl;
dgbsv_(&NN ,&kl, &ku, &nrhs, &AB[0], &ldab, &ipiv, &BB[0], &ldb, &info);
if (info == 0) {
for (int i = 0; i < NN; ++i) {
std::cout << BB[i] << ' ';
}
std::cout << std::endl;
} else {
std::cerr << "Something went wrong in dgbsv_()\n";
}
}