Commit f68544bc authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Features

operator () that return data in matrix form for TagRealArray and
TagVariableArray
parent 9689e3ce
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#if defined(USE_AUTODIFF) #if defined(USE_AUTODIFF)
#include "inmost_expression.h" #include "inmost_expression.h"
#endif #endif
#include "inmost_dense.h"
#if defined(USE_MESH) #if defined(USE_MESH)
...@@ -673,6 +673,13 @@ namespace INMOST ...@@ -673,6 +673,13 @@ namespace INMOST
TagRealArray & operator = (Tag const & b) {Tag::operator =(b); return *this;} TagRealArray & operator = (Tag const & b) {Tag::operator =(b); return *this;}
__INLINE Storage::real_array operator [](const Storage & arg) const {return arg.RealArray(*static_cast<const Tag*>(this));} __INLINE Storage::real_array operator [](const Storage & arg) const {return arg.RealArray(*static_cast<const Tag*>(this));}
__INLINE Storage::real_array operator [](HandleType h) const; __INLINE Storage::real_array operator [](HandleType h) const;
__INLINE Matrix<Storage::real,Storage::real_array> operator()(const Storage & arg, int n, int m) const
{
Storage::real_array data = arg.RealArray(*static_cast<const Tag*>(this));
assert(data.size() == n*m);
return Matrix<Storage::real,Storage::real_array>(data,n,m);
}
__INLINE Matrix<Storage::real,Storage::real_array> operator()(HandleType h, int n, int m) const;
}; };
class TagIntegerArray : public Tag class TagIntegerArray : public Tag
...@@ -734,6 +741,13 @@ namespace INMOST ...@@ -734,6 +741,13 @@ namespace INMOST
TagVariableArray & operator = (Tag const & b) {Tag::operator =(b); return *this;} TagVariableArray & operator = (Tag const & b) {Tag::operator =(b); return *this;}
__INLINE Storage::var_array operator [](const Storage & arg) const {return arg.VariableArray(*static_cast<const Tag*>(this));} __INLINE Storage::var_array operator [](const Storage & arg) const {return arg.VariableArray(*static_cast<const Tag*>(this));}
__INLINE Storage::var_array operator [](HandleType h) const; __INLINE Storage::var_array operator [](HandleType h) const;
__INLINE Matrix<Storage::var,Storage::var_array> operator()(const Storage & arg, int n, int m) const
{
Storage::var_array data = arg.VariableArray(*static_cast<const Tag*>(this));
assert(data.size() == n*m);
return Matrix<Storage::var,Storage::var_array>(data,n,m);
}
__INLINE Matrix<Storage::var,Storage::var_array> operator()(HandleType h, int n, int m) const;
}; };
#endif //USE_AUTODIFF #endif //USE_AUTODIFF
......
...@@ -553,9 +553,9 @@ namespace INMOST ...@@ -553,9 +553,9 @@ namespace INMOST
for(enumerator l = 0; l < Cols(); ++l) for(enumerator l = 0; l < Cols(); ++l)
{ {
if( fabs(get_value((*this)(k,l))) > threshold ) if( fabs(get_value((*this)(k,l))) > threshold )
std::cout << std::setw(10) << get_value((*this)(k,l)); std::cout << std::setw(12) << get_value((*this)(k,l));
else else
std::cout << std::setw(10) << 0; std::cout << std::setw(12) << 0;
std::cout << " "; std::cout << " ";
} }
std::cout << std::endl; std::cout << std::endl;
...@@ -815,10 +815,10 @@ namespace INMOST ...@@ -815,10 +815,10 @@ namespace INMOST
Matrix(enumerator pn, enumerator pm) : space(pn*pm), n(pn), m(pm) {} Matrix(enumerator pn, enumerator pm) : space(pn*pm), n(pn), m(pm) {}
/// Copy matrix. /// Copy matrix.
/// @param other Another matrix of the same type. /// @param other Another matrix of the same type.
Matrix(const Matrix & other) : space(other.n*other.m), n(other.n), m(other.m) Matrix(const Matrix & other) : space(other.space), n(other.n), m(other.m)
{ {
for(enumerator i = 0; i < n*m; ++i) //for(enumerator i = 0; i < n*m; ++i)
space[i] = other.space[i]; // space[i] = other.space[i];
} }
/// Construct matrix from matrix of different type. /// Construct matrix from matrix of different type.
/// Uses assign function declared in inmost_expression.h. /// Uses assign function declared in inmost_expression.h.
......
...@@ -3470,6 +3470,12 @@ namespace INMOST ...@@ -3470,6 +3470,12 @@ namespace INMOST
{ {
return GetMeshLink()->RealArray(h,*static_cast<const Tag*>(this)); return GetMeshLink()->RealArray(h,*static_cast<const Tag*>(this));
} }
__INLINE Matrix<Storage::real,Storage::real_array> TagRealArray::operator ()(HandleType h, int n, int m) const
{
Storage::real_array data = GetMeshLink()->RealArray(h,*static_cast<const Tag*>(this));
assert(data.size() == n*m);
return Matrix<Storage::real,Storage::real_array>(data,n,m);
}
__INLINE Storage::integer_array TagIntegerArray::operator [](HandleType h) const __INLINE Storage::integer_array TagIntegerArray::operator [](HandleType h) const
{ {
return GetMeshLink()->IntegerArray(h,*static_cast<const Tag*>(this)); return GetMeshLink()->IntegerArray(h,*static_cast<const Tag*>(this));
...@@ -3515,6 +3521,13 @@ namespace INMOST ...@@ -3515,6 +3521,13 @@ namespace INMOST
{ {
return GetMeshLink()->VariableArray(h,*static_cast<const Tag*>(this)); return GetMeshLink()->VariableArray(h,*static_cast<const Tag*>(this));
} }
__INLINE Matrix<Storage::var,Storage::var_array> TagVariableArray::operator ()(HandleType h, int n, int m) const
{
Storage::var_array data = GetMeshLink()->VariableArray(h,*static_cast<const Tag*>(this));
assert(data.size() == n*m);
return Matrix<Storage::var,Storage::var_array>(data,n,m);
}
#endif #endif
__INLINE bool Storage::HaveData(const Tag & tag) const __INLINE bool Storage::HaveData(const Tag & tag) const
{ {
......
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