Thank you Yves,

It seems that Hadamrd modules (SHAD, DHAD, CHAD and ZHAD) are available only 
through one of vendors (SGI SCSL ). I implemented element-wise matrix-matrix 
multiplication and it apears to me the naivest implementation (below). I don't 
know how I can improve the performance any better. Please let me knwo if you 
know you have any idea:

int  gmmElementwiseMatrixMultiply(gmm::dense_matrix<double> *A, 
gmm::dense_matrix<double> *B, gmm::dense_matrix<double> *C)
{
   typedef  gmm::dense_matrix<double>  MatrixType ;

    unsigned long int A_rows =  gmm::mat_nrows(*A) ;
    unsigned long int A_cols =  gmm::mat_ncols(*A) ;
    unsigned long int B_rows =  gmm::mat_nrows(*B) ;
    unsigned long int B_cols =  gmm::mat_ncols(*B) ;
    unsigned long int C_rows =  gmm::mat_nrows(*C) ;
    unsigned long int C_cols =  gmm::mat_ncols(*C) ;

    if ( (A_cols != B_cols) || (A_rows!=B_rows) || (A_cols != C_cols) ||  
(A_rows!=C_rows))
    {
       std::cout << "size of matrices should be the same!!" << std::endl ;
       return 0 ;
    }

    MatrixType::iterator    A_it  ;
    MatrixType::iterator    B_it = B->begin() ;
    MatrixType::iterator    C_it = C->begin() ;


    for (A_it = A->begin() ; A_it < A->end();A_it++)
    {
        (*C_it) = (*A_it)*(*B_it) ;
        C_it++;
        B_it++;
    }


}



Regards,
Kayhan



________________________________
From: Renard Yves <[email protected]>
To: Kayhan Batmanghelich <[email protected]>; [email protected]
Sent: Friday, May 8, 2009 8:54:07 AM
Subject: Re: [Getfem-users] Question about Hadamard product


Dear Kayhan,

The Hadamard vector product is not implemented in gmm. Of course it should not 
be difficult to implement it at least for dense vectors. It is similar to a sum 
of two vectors. The interface with the blas routines (SHAD, DHAD, CHAD and 
ZHAD) can be made also similarly to the sum of to dense vector (see 
gmm_blas_interface.h).


Yves.





Kayhan Batmanghelich <[email protected]> a écrit :

> Hello Everybody,
> 
> I have a question and I would be thankful if anybody answer:
> Part of my program needs efficient vector element-wise mutiplication. I was 
> wondering whether there is any command/function implemented in gmm or getfem 
> to interface with Hadamard vector product (element-wise vector product) in 
> the blas? If such module does not exist in las or gmm, what is the most 
> efficient way to do that?
> 
> 
> Regards,
> Kayhan
> 
> 
> 
> 


      
_______________________________________________
Getfem-users mailing list
[email protected]
https://mail.gna.org/listinfo/getfem-users

Reply via email to