Skylark (Sketching Library)
0.1
|
00001 #ifndef SKYLARK_EMPTY_MATRIX_HPP 00002 #define SKYLARK_EMPTY_MATRIX_HPP 00003 00004 #include "../../config.h" 00005 00006 #if SKYLARK_HAVE_COMBBLAS 00007 #include <CombBLAS.h> 00008 #endif 00009 00010 #if SKYLARK_HAVE_ELEMENTAL 00011 #include <elemental.hpp> 00012 #endif 00013 00014 namespace skylark { namespace utility { 00015 00019 template <typename MatrixOrVectorType> 00020 struct empty_matrix_t {}; 00021 00022 #if SKYLARK_HAVE_COMBBLAS 00023 00027 template <typename IndexType, 00028 typename ValueType> 00029 struct empty_matrix_t <FullyDistVec<IndexType, ValueType> > { 00030 typedef ValueType value_t; 00031 typedef IndexType index_t; 00032 typedef FullyDistVec<IndexType,ValueType> mpi_vector_t; 00033 00034 static mpi_vector_t generate (index_t& M) { 00035 return mpi_vector_t(M, 0); 00036 } 00037 }; 00038 00039 template <typename IndexType, 00040 typename ValueType> 00041 struct empty_matrix_t <FullyDistMultiVec<IndexType, ValueType> > { 00042 typedef ValueType value_t; 00043 typedef IndexType index_t; 00044 typedef FullyDistVec<IndexType,ValueType> mpi_vector_t; 00045 typedef FullyDistMultiVec<IndexType,ValueType> mpi_multi_vector_t; 00046 00047 static mpi_multi_vector_t generate (index_t M, 00048 index_t N) { 00049 /* Create an empty multi-vector */ 00050 return mpi_multi_vector_t(M /* dimension */, 00051 N /* number of vectors */, 00052 0 /* intial value */); 00053 } 00054 }; 00055 00056 template <typename IndexType, 00057 typename ValueType> 00058 struct empty_matrix_t <SpParMat<IndexType, 00059 ValueType, 00060 SpDCCols<IndexType, ValueType> > > { 00061 typedef IndexType index_t; 00062 typedef ValueType value_t; 00063 typedef SpDCCols<index_t,value_t> seq_matrix_t; 00064 typedef SpParMat<index_t,value_t, seq_matrix_t> mpi_matrix_t; 00065 typedef FullyDistVec<IndexType,ValueType> mpi_value_vector_t; 00066 typedef FullyDistVec<IndexType,IndexType> mpi_index_vector_t; 00067 00068 static mpi_matrix_t generate (index_t M, 00069 index_t N) { 00070 return mpi_matrix_t (M, 00071 N, 00072 mpi_index_vector_t(0, 0), 00073 mpi_index_vector_t(0, 0), 00074 mpi_index_vector_t(0, 0)); 00075 } 00076 }; 00077 00078 #endif // SKYLARK_HAVE_COMBBLAS 00079 00080 #if SKYLARK_HAVE_ELEMENTAL 00081 00082 template <typename ValueType> 00083 struct empty_matrix_t <elem::Matrix<ValueType> > { 00084 typedef int index_t; 00085 typedef ValueType value_t; 00086 typedef elem::Matrix<ValueType> matrix_t; 00087 00088 static matrix_t generate (index_t M, 00089 index_t N) { 00090 return matrix_t (M, N); 00091 } 00092 }; 00093 00094 template <typename ValueType, 00095 elem::Distribution CD, 00096 elem::Distribution RD> 00097 struct empty_matrix_t <elem::DistMatrix<ValueType, CD, RD> > { 00098 typedef int index_t; 00099 typedef ValueType value_t; 00100 typedef elem::DistMatrix<ValueType, CD, RD> mpi_matrix_t; 00101 00102 static mpi_matrix_t generate (index_t M, 00103 index_t N, 00104 elem::Grid& grid) { 00105 return mpi_matrix_t (M, N, grid); 00106 } 00107 }; 00108 00109 #endif // SKYLARK_HAVE_ELEMENTAL 00110 00111 } } 00113 #endif // SKYLARK_EMPTY_MATRIX_HPP