simpler conversion of std::vector
This commit is contained in:
@@ -198,6 +198,20 @@ struct conv_to_helper_Mat_same_type
|
||||
|
||||
return Mat<in_eT>(in.get_ref());
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Mat<in_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
const in_eT* in_memptr = (N > 0) ? &(in[0]) : nullptr;
|
||||
|
||||
return Mat<in_eT>(in_memptr, N, 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -220,6 +234,22 @@ struct conv_to_helper_Mat_diff_type
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Mat<out_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
Mat<out_eT> out(N, 1, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0) { arrayops::convert( out.memptr(), &(in[0]), N ); }
|
||||
|
||||
return out;
|
||||
}
|
||||
};
|
||||
@@ -344,16 +374,9 @@ conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_n
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
typedef typename conv_to_helper_Mat_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
Mat<out_eT> out(N, 1, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0)
|
||||
{
|
||||
arrayops::convert( out.memptr(), &(in[0]), N );
|
||||
}
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in);
|
||||
}
|
||||
|
||||
|
||||
@@ -426,6 +449,20 @@ struct conv_to_helper_Row_same_type
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Row<in_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
const in_eT* in_memptr = (N > 0) ? &(in[0]) : nullptr;
|
||||
|
||||
return Row<in_eT>(in_memptr, N);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -450,6 +487,22 @@ struct conv_to_helper_Row_diff_type
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Row<out_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
Row<out_eT> out(N, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0) { arrayops::convert( out.memptr(), &(in[0]), N ); }
|
||||
|
||||
return out;
|
||||
}
|
||||
};
|
||||
@@ -518,16 +571,9 @@ conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_n
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
typedef typename conv_to_helper_Row_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
Row<out_eT> out(N, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0)
|
||||
{
|
||||
arrayops::convert( out.memptr(), &(in[0]), N );
|
||||
}
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in);
|
||||
}
|
||||
|
||||
|
||||
@@ -600,6 +646,20 @@ struct conv_to_helper_Col_same_type
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Col<in_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
const in_eT* in_memptr = (N > 0) ? &(in[0]) : nullptr;
|
||||
|
||||
return Col<in_eT>(in_memptr, N);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -624,6 +684,22 @@ struct conv_to_helper_Col_diff_type
|
||||
|
||||
arrayops::convert( out.memptr(), X.memptr(), X.n_elem );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
inline
|
||||
static
|
||||
Col<out_eT>
|
||||
apply(const std::vector<in_eT>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
|
||||
Col<out_eT> out(N, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0) { arrayops::convert( out.memptr(), &(in[0]), N ); }
|
||||
|
||||
return out;
|
||||
}
|
||||
};
|
||||
@@ -692,16 +768,9 @@ conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename arma_n
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
const uword N = uword( in.size() );
|
||||
typedef typename conv_to_helper_Col_redirect<out_eT, in_eT, is_same_type<out_eT, in_eT>::value>::result helper_type;
|
||||
|
||||
Col<out_eT> out(N, arma_nozeros_indicator());
|
||||
|
||||
if(N > 0)
|
||||
{
|
||||
arrayops::convert( out.memptr(), &(in[0]), N );
|
||||
}
|
||||
|
||||
return out;
|
||||
return helper_type::apply(in);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user