Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 5c2b61d7 authored by hhakim's avatar hhakim
Browse files

Add a skeleton for Faust::MatDiag (yet to implement) and a starting test.

parent 7a562862
Branches
Tags
No related merge requests found
...@@ -192,7 +192,7 @@ if(MATIO_LIB_FILE AND MATIO_INC_DIR AND BUILD_READ_MAT_FILE) # AND HDF5_LIB_FILE ...@@ -192,7 +192,7 @@ if(MATIO_LIB_FILE AND MATIO_INC_DIR AND BUILD_READ_MAT_FILE) # AND HDF5_LIB_FILE
# faust_multiplication : time comparison between Faust-vector product and Dense matrix-vector product # faust_multiplication : time comparison between Faust-vector product and Dense matrix-vector product
foreach(TEST_FPP float double complex<float> complex<double>) foreach(TEST_FPP float double complex<float> complex<double>)
foreach(testin hierarchicalFactorization hierarchicalFactorizationFFT test_palm4MSA test_palm4MSAFFT faust_multiplication faust_matdense_conjugate GivensFGFT GivensFGFTParallel) foreach(testin hierarchicalFactorization hierarchicalFactorizationFFT test_palm4MSA test_palm4MSAFFT faust_multiplication faust_matdense_conjugate GivensFGFT GivensFGFTParallel test_MatDiag)
if(${TEST_FPP} MATCHES complex AND ${testin} MATCHES GivensFGFT) if(${TEST_FPP} MATCHES complex AND ${testin} MATCHES GivensFGFT)
continue() continue()
# GivensFGFT doesn't handle complex matrices # GivensFGFT doesn't handle complex matrices
......
#include "faust_MatDiag.h"
#include <cstdlib>
#include <complex>
using namespace Faust;
typedef @TEST_FPP@ FPP;
int main()
{
FPP data[3];
data[0] = FPP(1);
data[1] = FPP(2);
data[2] = FPP(3);
MatDiag<FPP> mdiag(10,data);
return EXIT_SUCCESS;
}
#ifndef __FAUST_MAT_DIAG__
#define __FAUST_MAT_DIAG__
#include <Eigen/Core>
#include "faust_constant.h"
#include "faust_Vect.h"
#include "faust_MatGeneric.h"
using namespace Eigen;
using namespace std;
namespace Faust
{
// template<typename FPP, Device DEVICE>
// class MatGeneric;
template<typename FPP>
class MatDiag : public MatGeneric<FPP,Cpu>
{
DiagonalMatrix<FPP,Dynamic> mat;
public:
MatDiag(faust_unsigned_int n): MatGeneric<FPP,Cpu>(n,n) {}
MatDiag(faust_unsigned_int n, FPP* data): MatGeneric<FPP,Cpu>(n,n)
{
Matrix<FPP, Dynamic, 1> v(n);
memcpy(v.data(), data, sizeof(FPP)*n);
mat = v.asDiagonal();
}
MatType getType() const { return Diag; }
MatGeneric<FPP,Cpu>* Clone(const bool isOptimize=false) const;
void multiply(Vect<FPP,Cpu> & vec, char opThis='N') const;
void multiply(MatDense<FPP,Cpu> & M, char opThis) const;
void transpose() { /* nothing to do */ }
void conjugate() { };//TODO:
faust_unsigned_int getNonZeros() const { return 0; } //TODO
matvar_t* toMatIOVar(bool transpose, bool conjugate) const;
FPP normL1(const bool transpose) const;
FPP norm() const;
FPP normL1(faust_unsigned_int& col_id, const bool transpose) const;
Vect<FPP,Cpu> get_col(faust_unsigned_int id) const;
void operator*=(const FPP alpha);
Vect<FPP,Cpu> multiply(const Vect<FPP,Cpu> &v) const;
void faust_gemm(const Faust::MatDense<FPP,Cpu> & B, Faust::MatDense<FPP,Cpu> & C,const FPP & alpha, const FPP & beta, char typeA, char typeB)const;
MatGeneric<FPP,Cpu>* get_cols(faust_unsigned_int col_id_start, faust_unsigned_int num_cols) const;
MatGeneric<FPP,Cpu>* get_rows(faust_unsigned_int row_id_start, faust_unsigned_int num_rows) const;
MatGeneric<FPP,Cpu>* get_cols(faust_unsigned_int* col_ids, faust_unsigned_int num_cols) const;
MatGeneric<FPP,Cpu>* get_rows(faust_unsigned_int* row_ids, faust_unsigned_int num_rows) const;
};
#include "faust_MatDiag.hpp"
}
#endif
template<typename FPP>
void MatDiag<FPP>::operator*=(const FPP alpha)
{
}
template<typename FPP>
void MatDiag<FPP>::faust_gemm(const Faust::MatDense<FPP,Cpu> & B, Faust::MatDense<FPP,Cpu> & C,const FPP & alpha, const FPP & beta, char typeA, char typeB)const
{
}
template<typename FPP>
Vect<FPP,Cpu> MatDiag<FPP>::multiply(const Vect<FPP,Cpu> &v) const
{
Vect<FPP,Cpu> v_(v);
return v;
}
template<typename FPP>
void MatDiag<FPP>::multiply(Vect<FPP,Cpu> & vec, char opThis) const
{
//TODO
}
template<typename FPP>
void MatDiag<FPP>::multiply(MatDense<FPP,Cpu> & M, char opThis) const
{
//TODO
}
template<typename FPP>
MatGeneric<FPP,Cpu>* MatDiag<FPP>::Clone(const bool isOptimize) const
{
//TODO
return nullptr;
}
template<typename FPP>
matvar_t* MatDiag<FPP>::toMatIOVar(bool transpose, bool conjugate) const
{
//TODO
return nullptr;
}
template<typename FPP>
FPP MatDiag<FPP>::normL1(const bool transpose) const
{
//TODO
return FPP(0);
}
template<typename FPP>
FPP MatDiag<FPP>::norm() const
{
//TODO
return FPP(0);
}
template<typename FPP>
FPP MatDiag<FPP>::normL1(faust_unsigned_int& col_id, const bool transpose) const
{
//TODO
return FPP(0);
}
template<typename FPP>
Vect<FPP,Cpu> MatDiag<FPP>::get_col(faust_unsigned_int id) const
{
//TODO
Vect<FPP,Cpu> v;
return v;
}
template<typename FPP>
MatGeneric<FPP,Cpu>* MatDiag<FPP>::get_cols(faust_unsigned_int col_id_start, faust_unsigned_int num_cols) const
{
//TODO
return nullptr;
}
template<typename FPP>
MatGeneric<FPP,Cpu>* MatDiag<FPP>::get_rows(faust_unsigned_int row_id_start, faust_unsigned_int num_rows) const
{
//TODO
return nullptr;
}
template<typename FPP>
MatGeneric<FPP,Cpu>* MatDiag<FPP>::get_cols(faust_unsigned_int* col_ids, faust_unsigned_int num_cols) const
{
//TODO
return nullptr;
}
template<typename FPP>
MatGeneric<FPP,Cpu>* MatDiag<FPP>::get_rows(faust_unsigned_int* row_ids, faust_unsigned_int num_rows) const
{
//TODO
return nullptr;
}
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#define FAUST_CONSTANT_H #define FAUST_CONSTANT_H
#define FAUST_VERSION 2.0 #define FAUST_VERSION @CPACK_PACKAGE_VERSION@
///if defined, compilation with openblas for dense algebra ///if defined, compilation with openblas for dense algebra
#cmakedefine __GEMM_WITH_OPENBLAS__ #cmakedefine __GEMM_WITH_OPENBLAS__
...@@ -89,6 +89,7 @@ enum MatType ...@@ -89,6 +89,7 @@ enum MatType
{ {
Dense, Dense,
Sparse, Sparse,
Diag
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment