Commit c369ee86 authored by Kirill Terekhov's avatar Kirill Terekhov

Additional updates to template handling in AbstractEntry::Access, fix a bug in...

Additional updates to template handling in AbstractEntry::Access, fix a bug in thread_private class with openmp
parent b21617f0
...@@ -11,13 +11,19 @@ ...@@ -11,13 +11,19 @@
namespace INMOST namespace INMOST
{ {
template<> Matrix<INMOST_DATA_REAL_TYPE> AbstractEntry::Access(const Storage& e) const {return Value(e);}
template<> Matrix<INMOST_DATA_INTEGER_TYPE> AbstractEntry::Access(const Storage& e) const {return Index(e);}
template<> Matrix<unknown> AbstractEntry::Access(const Storage& e) const {return Unknown(e);}
template<> INMOST_DATA_REAL_TYPE AbstractEntry::Access(const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Value(e,pos);} template<> Demote<INMOST_DATA_REAL_TYPE>::type AbstractEntry::Access<INMOST_DATA_REAL_TYPE> (const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Value(e,pos);}
template<> INMOST_DATA_INTEGER_TYPE AbstractEntry::Access(const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Index(e,pos);} template<> Demote<INMOST_DATA_INTEGER_TYPE>::type AbstractEntry::Access<INMOST_DATA_INTEGER_TYPE>(const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Index(e,pos);}
template<> unknown AbstractEntry::Access(const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Unknown(e,pos);} template<> Demote<unknown>::type AbstractEntry::Access<unknown> (const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Unknown(e,pos);}
template<> Demote<variable>::type AbstractEntry::Access<variable> (const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Unknown(e,pos);}
template<> Demote<hessian_variable>::type AbstractEntry::Access<hessian_variable> (const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Unknown(e,pos);}
template<> Matrix<typename Demote<INMOST_DATA_REAL_TYPE>::type> AbstractEntry::Access<INMOST_DATA_REAL_TYPE> (const Storage& e) const {return Value(e);}
template<> Matrix<typename Demote<INMOST_DATA_INTEGER_TYPE>::type> AbstractEntry::Access<INMOST_DATA_INTEGER_TYPE>(const Storage& e) const {return Index(e);}
template<> Matrix<typename Demote<unknown>::type> AbstractEntry::Access<unknown> (const Storage& e) const {return Unknown(e);}
template<> Matrix<typename Demote<variable>::type> AbstractEntry::Access<variable> (const Storage& e) const {return Unknown(e);}
template<> Matrix<typename Demote<hessian_variable>::type> AbstractEntry::Access<hessian_variable> (const Storage& e) const {return Unknown(e);}
#if defined(USE_MESH) #if defined(USE_MESH)
Automatizator * Automatizator::CurrentAutomatizator = NULL; Automatizator * Automatizator::CurrentAutomatizator = NULL;
......
...@@ -2799,8 +2799,8 @@ namespace INMOST ...@@ -2799,8 +2799,8 @@ namespace INMOST
const T & get() const {return items[omp_get_thread_num()].item;} const T & get() const {return items[omp_get_thread_num()].item;}
T & get(int k) {return items[k].item;} T & get(int k) {return items[k].item;}
const T & get(int k) const {return items[k].item;} const T & get(int k) const {return items[k].item;}
T * operator ->() {return get();} T * operator ->() {return &items[omp_get_thread_num()].item;}
const T * operator ->() const {return get();} const T * operator ->() const {return &items[omp_get_thread_num()].item;}
}; };
#else //_OPENMP #else //_OPENMP
template<typename T> template<typename T>
......
...@@ -11,6 +11,14 @@ namespace INMOST ...@@ -11,6 +11,14 @@ namespace INMOST
{ {
class Automatizator; //forward declaration class Automatizator; //forward declaration
//return specific type with specific template
template<class T> struct Demote;
template<> struct Demote<INMOST_DATA_INTEGER_TYPE> {typedef INMOST_DATA_INTEGER_TYPE type;};
template<> struct Demote<INMOST_DATA_REAL_TYPE> {typedef INMOST_DATA_REAL_TYPE type;};
template<> struct Demote<unknown> {typedef unknown type;};
template<> struct Demote<variable> {typedef unknown type;};
template<> struct Demote<hessian_variable> {typedef unknown type;};
/// This class is used to organize unknowns in abstract way, /// This class is used to organize unknowns in abstract way,
/// it should be registered with and managed by class Automatizator. /// it should be registered with and managed by class Automatizator.
/// \todo /// \todo
...@@ -62,11 +70,11 @@ namespace INMOST ...@@ -62,11 +70,11 @@ namespace INMOST
virtual uMatrix Unknown(const Storage & e) const = 0; virtual uMatrix Unknown(const Storage & e) const = 0;
/// Return vector filled with either values or indices or unknowns of the block, /// Return vector filled with either values or indices or unknowns of the block,
/// depending on the template parameter. /// depending on the template parameter.
template<typename T> Matrix<T> Access(const Storage &e) const; template<typename T> Matrix<typename Demote<T>::type> Access(const Storage &e) const;
/// Return either value or index or unknown at specified position of the block, /// Return either value or index or unknown at specified position of the block,
/// depending on the template parameter. /// depending on the template parameter.
/// @param pos Position in the block, should be no larger then MatrixSize. /// @param pos Position in the block, should be no larger then MatrixSize.
template<typename T> T Access(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const; template<typename T> typename Demote<T>::type Access(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const;
/// Return vector filled with unknowns of the block with their derivatives. /// Return vector filled with unknowns of the block with their derivatives.
virtual uMatrix operator [](const Storage & e) const = 0; virtual uMatrix operator [](const Storage & e) const = 0;
/// The intended size of the matrix for this entry. /// The intended size of the matrix for this entry.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment