Commit 3f4c373f by Francois Gygi

Added getsub member for copy of arbitrary block with arbitrary destination


git-svn-id: http://qboxcode.org/svn/qb/trunk@724 cba15fb0-1239-40c8-b417-11db7ca47a34
parent ca1fe06c
......@@ -15,7 +15,7 @@
// Matrix.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: Matrix.C,v 1.19 2008-09-08 15:56:18 fgygi Exp $
// $Id: Matrix.C,v 1.20 2009-09-08 05:37:41 fgygi Exp $
#include <cassert>
#include <iostream>
......@@ -930,8 +930,34 @@ void DoubleMatrix::getsub(const DoubleMatrix &a,
}
////////////////////////////////////////////////////////////////////////////////
// real getsub: *this = sub(A)
// copy submatrix A(ia:ia+m, ja:ja+n) into *this(idest:idest+m,jdest:jdest+n)
// *this and A may live in different contexts
void DoubleMatrix::getsub(const DoubleMatrix &a,
int m, int n, int isrc, int jsrc, int idest, int jdest)
{
#if SCALAPACK
int iap=isrc+1;
int jap=jsrc+1;
int idp=idest+1;
int jdp=jdest+1;
assert(n<=n_);
assert(n<=a.n());
assert(m<=m_);
assert(m<=a.m());
int gictxt;
Cblacs_get( 0, 0, &gictxt );
pdgemr2d(&m,&n,a.val,&iap,&jap,a.desc_,val,&idp,&jdp,desc_,&gictxt);
#else
for ( int j = 0; j < n; j++ )
for ( int i = 0; i < m; i++ )
val[(idest+i)+(jdest+j)*m_] = a.val[(i+isrc) + (j+jsrc)*a.m()];
#endif
}
////////////////////////////////////////////////////////////////////////////////
// complex getsub: *this = sub(A)
// copy submatrix A(ia:ia+m, ja:ja+n) into *this;
// copy submatrix A(ia:ia+m, ja:ja+n) into *this
// *this and A may live in different contexts
void ComplexMatrix::getsub(const ComplexMatrix &a,
int m, int n, int ia, int ja)
......@@ -955,6 +981,32 @@ void ComplexMatrix::getsub(const ComplexMatrix &a,
}
////////////////////////////////////////////////////////////////////////////////
// complex getsub: *this = sub(A)
// copy submatrix A(ia:ia+m, ja:ja+n) into *this(idest:idest+m,jdest:jdest+n)
// *this and A may live in different contexts
void ComplexMatrix::getsub(const ComplexMatrix &a,
int m, int n, int isrc, int jsrc, int idest, int jdest)
{
#if SCALAPACK
int iap=isrc+1;
int jap=jsrc+1;
int idp=idest+1;
int jdp=jdest+1;
assert(n<=n_);
assert(n<=a.n());
assert(m<=m_);
assert(m<=a.m());
int gictxt;
Cblacs_get( 0, 0, &gictxt );
pzgemr2d(&m,&n,a.val,&iap,&jap,a.desc_,val,&idp,&jdp,desc_,&gictxt);
#else
for ( int j = 0; j < n; j++ )
for ( int i = 0; i < m; i++ )
val[(idest+i)+(jdest+j)*m_] = a.val[(i+isrc) + (j+jsrc)*a.m()];
#endif
}
////////////////////////////////////////////////////////////////////////////////
// real matrix transpose
// this = alpha * transpose(A) + beta * this
////////////////////////////////////////////////////////////////////////////////
......
......@@ -15,7 +15,7 @@
// Matrix.h
//
////////////////////////////////////////////////////////////////////////////////
// $Id: Matrix.h,v 1.18 2008-09-08 15:56:18 fgygi Exp $
// $Id: Matrix.h,v 1.19 2009-09-08 05:37:41 fgygi Exp $
#ifndef MATRIX_H
#define MATRIX_H
......@@ -204,6 +204,11 @@ class DoubleMatrix
// get submatrix A(ia:ia+m,ja:ja+n) of A
void getsub(const DoubleMatrix& a,int m,int n,int ia,int ja);
// get submatrix A(ia:ia+m,ja:ja+n) of A and store in
// this(idest:idest+m,jdest:jdest+n)
void getsub(const DoubleMatrix& a,int m,int n,int isrc,int jsrc,
int idest, int jdest);
// matrix * matrix
// this = alpha*op(A)*op(B)+beta*this
void gemm(char transa, char transb,
......@@ -460,6 +465,11 @@ class ComplexMatrix
// get submatrix A(ia:ia+m,ja:ja+n) of A
void getsub(const ComplexMatrix& a, int m, int n, int ia, int ja);
// get submatrix A(ia:ia+m,ja:ja+n) of A and store in
// this(idest:idest+m,jdest:jdest+n)
void getsub(const ComplexMatrix& a,int m,int n,int isrc,int jsrc,
int idest, int jdest);
// matrix * matrix
// this = alpha*op(A)*op(B)+beta*this
void gemm(char transa, char transb,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment