#include "Didasko_ConfigDefs.h"
#if defined(HAVE_DIDASKO_EPETRA) && defined(HAVE_DIDASKO_TRIUTILS)
#include "Epetra_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif
#include "Epetra_Map.h"
#include "Epetra_MultiVector.h"
#include "Epetra_Vector.h"
#include "Epetra_RowMatrix.h"
#include "Trilinos_Util.h"
{
public:
MSRMatrix(
Epetra_Map Map,
int * bindx,
double * val) :
bindx_(bindx),
val_(val),
Map_(Map)
{
}
~MSRMatrix()
{}
{
int Nrows = bindx_[0]-1;
for( int i=0 ; i<Nrows ; i++ ) {
for( int vec=0 ; vec<X.NumVectors() ; ++vec ) {
Y[vec][i] = val_[i]*X[vec][i];
}
for( int j=bindx_[i] ; j<bindx_[i+1] ; j++ ) {
for( int vec=0 ; vec<X.NumVectors() ; ++vec ) {
Y[vec][bindx_[j]] += val_[j]*X[vec][bindx_[j]];
}
}
}
return 0;
}
{
return(-1);
}
{
return(-1);
}
{
return -1;
}
const char*
Label ()
const
{
return "TriDiagonalOperator";
}
{
return false;
}
{
return true;
}
{
return( Map_.Comm() );
}
{
return( Map_ );
}
{
return( Map_ );
}
private:
int * bindx_;
double * val_;
};
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc, &argv);
#else
#endif
cerr << "*ERR* can be used only with one process" << endl;
#ifdef HAVE_MPI
MPI_Finalize();
#endif
exit(EXIT_SUCCESS);
}
int N_global;
int N_nonzeros;
double * val = NULL;
int * bindx = NULL;
double * x = NULL, * b = NULL, * xexact = NULL;
FILE* fp = fopen("../HBMatrices/fidap005.rua", "r");
if (fp == 0)
{
cerr << "Matrix file not available" << endl;
#ifdef HAVE_MPI
MPI_Finalize();
#endif
exit(EXIT_SUCCESS);
}
fclose(fp);
Trilinos_Util_read_hb("../HBMatrices/fidap005.rua", 0,
&N_global, &N_nonzeros,
&val, &bindx,
&x, &b, &xexact);
MSRMatrix A(Map,bindx,val);
xxx.Random();
A.Apply(xxx,yyy);
cout << yyy;
double norm2;
yyy.Norm2(&norm2);
cout << norm2 << endl;
if (val != NULL) free((void*)val);
if (bindx != NULL) free((void*)bindx);
if (x != NULL) free((void*)x);
if (b != NULL) free((void*)b);
if (xexact != NULL) free((void*)xexact);;
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return(EXIT_SUCCESS);
}
#else
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
puts("Please configure Didasko with:\n"
"--enable-epetra\n"
"--enable-triutils");
return(0);
}
#endif