Add sparse matrix.
This commit is contained in:
29
src/Sparse.cpp
Normal file
29
src/Sparse.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "Sparse.h"
|
||||
#include "Matrix.h"
|
||||
namespace Aurora
|
||||
{
|
||||
Sparse::Sparse()
|
||||
{
|
||||
}
|
||||
|
||||
Sparse::~Sparse()
|
||||
{
|
||||
}
|
||||
|
||||
Sparse::Sparse(Matrix& Cols, Matrix& Rows, Matrix& Values,size_t M, size_t N)
|
||||
: mColIdxVector(Cols),
|
||||
mRowIdxVector(Rows),
|
||||
mValueVector(Values),
|
||||
mM(M),
|
||||
mN(N)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Sparse::isValid() const
|
||||
{
|
||||
return mColIdxVector.isVector() && mRowIdxVector.isVector() && mValueVector.isVector()
|
||||
&& mColIdxVector.getDataSize() == mRowIdxVector.getDataSize()
|
||||
&& mColIdxVector.getDataSize() == mValueVector.getDataSize();
|
||||
}
|
||||
}
|
||||
26
src/Sparse.h
Normal file
26
src/Sparse.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef __SPARSE_H__
|
||||
#define __SPARSE_H__
|
||||
#include "Matrix.h"
|
||||
#include <cstddef>
|
||||
namespace Aurora {
|
||||
class Sparse
|
||||
{
|
||||
public:
|
||||
Sparse();
|
||||
Sparse(Matrix& Cols, Matrix& Rows, Matrix& Values,size_t M, size_t N);
|
||||
~Sparse();
|
||||
bool isValid() const;
|
||||
// TODO:add operators
|
||||
private:
|
||||
Matrix mColIdxVector;
|
||||
Matrix mRowIdxVector;
|
||||
Matrix mValueVector;
|
||||
std::size_t mM;//row count
|
||||
std::size_t mN;//col count
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __SPARSE_H__
|
||||
Reference in New Issue
Block a user