2015-04-18 18:47:43 +01:00
|
|
|
#ifndef GRID_MATH_POKE_H
|
|
|
|
#define GRID_MATH_POKE_H
|
|
|
|
namespace Grid {
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Poke a specific index;
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2015-06-30 15:17:27 +01:00
|
|
|
#if 0
|
2015-04-18 18:47:43 +01:00
|
|
|
// Scalar poke
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,typename std::enable_if< iScalar<vtype>::TensorLevel == Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iScalar<vtype> &ret, const iScalar<vtype> &arg)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
ret._internal = arg._internal;
|
|
|
|
}
|
|
|
|
// Vector poke, one index
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,int N,typename std::enable_if< iScalar<vtype>::TensorLevel == Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iVector<vtype,N> &ret, const iScalar<vtype> &arg,int i)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
ret._internal[i] = arg._internal;
|
|
|
|
}
|
2015-06-30 15:17:27 +01:00
|
|
|
//Matrix poke, two indices
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,int N,typename std::enable_if< iScalar<vtype>::TensorLevel == Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iMatrix<vtype,N> &ret, const iScalar<vtype> &arg,int i,int j)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
ret._internal[i][j] = arg._internal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
// No match poke for scalar,vector,matrix must forward on either 0,1,2 args. Must have 9 routines with notvalue
|
|
|
|
/////////////
|
|
|
|
// scalar
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iScalar<vtype> &ret, const iScalar<decltype(peekIndex<Level>(ret._internal))> &arg)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
pokeIndex<Level>(ret._internal,arg._internal);
|
|
|
|
}
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iScalar<vtype> &ret, const iScalar<decltype(peekIndex<Level>(ret._internal,0))> &arg, int i)
|
2015-04-18 18:47:43 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
pokeIndex<Level>(ret._internal,arg._internal,i);
|
|
|
|
}
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iScalar<vtype> &ret, const iScalar<decltype(peekIndex<Level>(ret._internal,0,0))> &arg,int i,int j)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
pokeIndex<Level>(ret._internal,arg._internal,i,j);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Vector
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,int N,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iVector<vtype,N> &ret, iVector<decltype(peekIndex<Level>(ret._internal)),N> &arg)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
for(int ii=0;ii<N;ii++){
|
|
|
|
pokeIndex<Level>(ret._internal[ii],arg._internal[ii]);
|
|
|
|
}
|
|
|
|
}
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,int N,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iVector<vtype,N> &ret, const iVector<decltype(peekIndex<Level>(ret._internal,0)),N> &arg,int i)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
for(int ii=0;ii<N;ii++){
|
|
|
|
pokeIndex<Level>(ret._internal[ii],arg._internal[ii],i);
|
|
|
|
}
|
|
|
|
}
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,int N,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iVector<vtype,N> &ret, const iVector<decltype(peekIndex<Level>(ret._internal,0,0)),N> &arg,int i,int j)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
for(int ii=0;ii<N;ii++){
|
|
|
|
pokeIndex<Level>(ret._internal[ii],arg._internal[ii],i,j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Matrix
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,int N,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iMatrix<vtype,N> &ret, const iMatrix<decltype(peekIndex<Level>(ret._internal)),N> &arg)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
for(int ii=0;ii<N;ii++){
|
|
|
|
for(int jj=0;jj<N;jj++){
|
|
|
|
pokeIndex<Level>(ret._internal[ii][jj],arg._internal[ii][jj]);
|
|
|
|
}}
|
|
|
|
}
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,int N,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iMatrix<vtype,N> &ret, const iMatrix<decltype(peekIndex<Level>(ret._internal,0)),N> &arg,int i)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
for(int ii=0;ii<N;ii++){
|
|
|
|
for(int jj=0;jj<N;jj++){
|
|
|
|
pokeIndex<Level>(ret._internal[ii][jj],arg._internal[ii][jj],i);
|
|
|
|
}}
|
|
|
|
}
|
2015-05-15 11:42:51 +01:00
|
|
|
template<int Level,class vtype,int N,typename std::enable_if< iScalar<vtype>::TensorLevel != Level >::type * =nullptr> inline
|
|
|
|
void pokeIndex(iMatrix<vtype,N> &ret, const iMatrix<decltype(peekIndex<Level>(ret._internal,0,0)),N> &arg, int i,int j)
|
2015-04-18 18:47:43 +01:00
|
|
|
{
|
|
|
|
for(int ii=0;ii<N;ii++){
|
|
|
|
for(int jj=0;jj<N;jj++){
|
|
|
|
pokeIndex<Level>(ret._internal[ii][jj],arg._internal[ii][jj],i,j);
|
|
|
|
}}
|
|
|
|
}
|
2015-06-30 15:17:27 +01:00
|
|
|
#endif
|
2015-04-18 18:47:43 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|