index info compiles...

This commit is contained in:
Christian Zimmermann 2017-12-25 01:35:09 +01:00
parent 9e3e866b06
commit c349ff7bd0
4 changed files with 73 additions and 5 deletions

View file

@ -22,7 +22,7 @@ endif()
include_directories(src)
set(INDEX_CC_FILES "${INDEX_CC_FILES}" "src/ranges/range_base.cc")
set(INDEX_CC_FILES "${INDEX_CC_FILES}" "src/ranges/range_base.cc" "src/ranges/index_info.cc")
set(MA_CC_FILES "${MA_CC_FILES}" "${INDEX_CC_FILES}" "src/operation_utils.cc")
add_executable(iutest src/ranges/tests/index_unit_test.cc ${INDEX_CC_FILES})

View file

@ -1,9 +1,41 @@
#include "index_info.h"
#include "range_base.h"
namespace MultiArrayTools
{
bool IndexInfo::operator==(const IndexInfo& in) const
{
return mPtrNum == in.mPtrNum;
}
bool IndexInfo::operator!=(const IndexInfo& in) const
{
return mPtrNum != in.mPtrNum;
}
bool IndexInfo::operator<=(const IndexInfo& in) const
{
return mPtrNum <= in.mPtrNum;
}
bool IndexInfo::operator<(const IndexInfo& in) const
{
return mPtrNum < in.mPtrNum;
}
bool IndexInfo::operator>(const IndexInfo& in) const
{
return mPtrNum > in.mPtrNum;
}
bool IndexInfo::operator>=(const IndexInfo& in) const
{
return mPtrNum >= in.mPtrNum;
}
const IndexInfo* IndexInfo::getPtr(size_t inum) const
{
return &mNext[inum];
@ -18,10 +50,15 @@ namespace MultiArrayTools
{
return mDim;
}
size_t IndexInfo::max() const
{
return mMax;
}
size_t IndexInfo::getStepSize(size_t inum) const
{
return mNext[inum]->getStepSzize();
return mNext[inum].getStepSize();
}
size_t IndexInfo::getStepSize() const
@ -29,5 +66,9 @@ namespace MultiArrayTools
return mStepSize;
}
IndexType IndexInfo::type() const
{
return mType;
}
} // end namespace MultiArrayTools

View file

@ -4,7 +4,11 @@
#define __index_info_h__
#include <cstdlib>
#include <cstdint>
#include <vector>
#include <memory>
#include "vindex_base.h"
#include "index_type.h"
namespace MultiArrayTools
{
@ -13,29 +17,51 @@ namespace MultiArrayTools
class IndexInfo
{
public:
IndexInfo() = delete;
IndexInfo(IndexInfo&& in) = default;
IndexInfo& operator=(IndexInfo&& in) = default;
IndexInfo(const IndexInfo& in) = default;
IndexInfo& operator=(const IndexInfo& in) = default;
template <class IndexClass>
IndexInfo(const IndexClass& ind, size_t stepSize = 1);
bool operator==(const IndexInfo& in) const;
bool operator!=(const IndexInfo& in) const;
bool operator<=(const IndexInfo& in) const;
bool operator<(const IndexInfo& in) const;
bool operator>(const IndexInfo& in) const;
bool operator>=(const IndexInfo& in) const;
const IndexInfo* getPtr(size_t inum) const;
std::intptr_t getPtrNum() const;
size_t dim() const;
size_t max() const;
size_t getStepSize(size_t inum) const;
size_t getStepSize() const;
IndexType type() const;
private:
IndexInfo() = default;
std::vector<IndexInfo> mNext;
std::intptr_t mPtrNum;
size_t mDim;
size_t mMax;
size_t mStepSize;
IndexType mType;
};
template <class IndexClass>
IndexInfo::IndexInfo(const IndexClass& ind, size_t stepSize) :
mNext(ind.infoVec()),
mPtrNum( reinterpret_cast<std::intptr_t>( &ind ) ),
mDim(ind.rangePtr()->dim()),
mDim(ind.vrange()->dim()),
mMax(ind.max()),
mStepSize(stepSize)
{}

View file

@ -4,6 +4,7 @@
//#include "ranges/range_base.h"
#include "ranges/index_type.h"
#include "base_def.h"
namespace MultiArrayTools
{