Ionut Borcoman at debian wrote:
> 
> Drake Diedrich wrote:
> >
> >    Lapack++ hasn't been packaged yet, but would be welcome.  The successor,
> > NTL, might be a better time investment.  http://math.nist.gov/tnt/
> 
> After some strugle, I've managed to compile Lapack++. The tests included
> in the distribution (the netlib one) said it's OK. I have also made the
> shared libs. As this is my first attept to make a shared lib, please
> tell me if the commnads are OK. Here are some lines from one of the
> makefile:

Lapack++ disappointed me very much. There are 2 posibilities: 
(a) I've compiled it wrong
(b) it was left unfinished.
Anyhow, I was unable to use it at what I whant: to solve banded systems.

The package 'cfortran', sugested by Christopher Lee
<[EMAIL PROTECTED]> looked more appropriate for what I'm needing.
Unfortunately, it doesn't work for matrixes bigger than 14x14. Or maybe
I've done again something wrong.

However, I was able to use matrixes how big I've choosed using my own
IsFMatrix class. And here is my problem: I cam write this class in two
ways, but I do not know which one is better. One needs more memory,
while the other uses some extra operations for indexing. Here they are:

// variant 1: uses a multiply in the indexing

template <class T> 
class IsFMatrix
{
public:
  int rows, cols;
  T *data;
  
  IsFMatrix(int aRows, int aCols){rows=aRows; cols=aCols; data = new
T[rows*cols];};
  ~IsFMatrix(void) {delete [] data;};
  T& operator()(int i, int j) {return data[j*rows+i];}; // I use a
multiply to index
};

// call example for variant 1
  IsFMatrix<float> ab(ldab,n);  
  ...
  sgbtrf_( &m, 
           &n, 
           &kl, 
           &ku, 
           ab.data, // variant 1
           &ldab, 
           ipiv, 
           &info);


// variant 2: uses more memory
template <class T> 
class IsFMatrix
{
public:
  int rows, cols;
  T **data;
  
  IsFMatrix(int aRows, int aCols);
  ~IsFMatrix(void){ delete [] (*data); delete [] data;};
  T& operator()(int i, int j){return data[j][i];};
};

template <class T> 
IsFMatrix<T>::IsFMatrix(int aRows, int aCols)
{
  T *p;
  
  rows = aRows;
  cols = aCols;
  
  p = new T[rows*cols];
  data = new T*[cols];  // this memory is "wasted"
  for(int j=0; j<cols; j++){
    data[j] = p;
    p += rows;
  }
}

// call example for variant 2
  IsFMatrix<float> ab(ldab,n);  
  ...
  sgbtrf_( &m, 
           &n, 
           &kl, 
           &ku, 
           ab.data[0], // variant 2
           &ldab, 
           ipiv, 
           &info);

The prototype for sgbtrf_ is:

void
sgbtrf_(int *m,
        int *n,
        int *kl,
        int *ku,
        float *ab,
        int *ldab,
        int *ipiv,
        int *info);


I tend to like more variant 1, since variant 2 can waste a lot of memory
if matrixes are big. 

Thanks,

Ionutz


--  
Unsubscribe?  mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to