本文整理汇总了C++中ProxyCube::get_n_elem方法的典型用法代码示例。如果您正苦于以下问题:C++ ProxyCube::get_n_elem方法的具体用法?C++ ProxyCube::get_n_elem怎么用?C++ ProxyCube::get_n_elem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProxyCube
的用法示例。
在下文中一共展示了ProxyCube::get_n_elem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: A
arma_hot
arma_warn_unused
inline
typename T1::elem_type
accu(const BaseCube<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> A(X.get_ref());
ea_type P = A.get_ea();
const u32 n_elem = A.get_n_elem();
eT val1 = eT(0);
eT val2 = eT(0);
u32 i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
val1 += P[i];
val2 += P[j];
}
if(i < n_elem)
{
val1 += P[i];
}
return val1 + val2;
}
示例2: A
arma_hot
arma_warn_unused
inline
typename T1::elem_type
accu(const BaseCube<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
typedef typename ProxyCube<T1>::ea_type ea_type;
const ProxyCube<T1> A(X.get_ref());
if(ProxyCube<T1>::prefer_at_accessor == false)
{
ea_type P = A.get_ea();
const uword n_elem = A.get_n_elem();
eT val1 = eT(0);
eT val2 = eT(0);
uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
val1 += P[i];
val2 += P[j];
}
if(i < n_elem)
{
val1 += P[i];
}
return val1 + val2;
}
else
{
const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
const uword n_slices = A.get_n_slices();
eT val = eT(0);
for(uword slice=0; slice<n_slices; ++slice)
{
for(uword col=0; col<n_cols; ++col)
{
for(uword row=0; row<n_rows; ++row)
{
val += A.at(row,col,slice);
}
}
}
return val;
}
}
示例3: tmp
inline
void
op_vectorise_cube_col::apply_proxy(Mat<typename T1::elem_type>& out, const ProxyCube<T1>& P)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const uword N = P.get_n_elem();
out.set_size(N, 1);
if(is_Cube<typename ProxyCube<T1>::stored_type>::value == true)
{
const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp(P.Q);
arrayops::copy(out.memptr(), tmp.M.memptr(), N);
}
else
{
eT* outmem = out.memptr();
if(ProxyCube<T1>::use_at == false)
{
typename ProxyCube<T1>::ea_type A = P.get_ea();
uword i,j;
for(i=0, j=1; j < N; i+=2, j+=2)
{
const eT tmp_i = A[i];
const eT tmp_j = A[j];
outmem[i] = tmp_i;
outmem[j] = tmp_j;
}
if(i < N)
{
outmem[i] = A[i];
}
}
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
const uword n_slices = P.get_n_slices();
for(uword slice=0; slice < n_slices; ++slice)
for(uword col=0; col < n_cols; ++col )
for(uword row=0; row < n_rows; ++row )
{
*outmem = P.at(row,col,slice);
outmem++;
}
}
}
}
示例4:
inline
typename arma_not_cx<typename T1::elem_type>::result
op_min::min_with_index(const ProxyCube<T1>& P, uword& index_of_min_val)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const uword n_elem = P.get_n_elem();
if(n_elem == 0)
{
arma_debug_check(true, "min(): object has no elements");
return Datum<eT>::nan;
}
eT best_val = priv::most_pos<eT>();
uword best_index = 0;
if(ProxyCube<T1>::use_at == false)
{
typedef typename ProxyCube<T1>::ea_type ea_type;
ea_type A = P.get_ea();
for(uword i=0; i < n_elem; ++i)
{
const eT tmp = A[i];
if(tmp < best_val) { best_val = tmp; best_index = i; }
}
}
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
const uword n_slices = P.get_n_slices();
uword count = 0;
for(uword slice=0; slice < n_slices; ++slice)
for(uword col=0; col < n_cols; ++col )
for(uword row=0; row < n_rows; ++row )
{
const eT tmp = P.at(row,col,slice);
if(tmp < best_val) { best_val = tmp; best_index = count; }
++count;
}
}
index_of_min_val = best_index;
return best_val;
}
示例5:
inline
void
glue_max::apply(Cube< std::complex<T> >& out, const ProxyCube<T1>& PA, const ProxyCube<T2>& PB)
{
arma_extra_debug_sigprint();
typedef typename std::complex<T> eT;
const uword n_rows = PA.get_n_rows();
const uword n_cols = PA.get_n_cols();
const uword n_slices = PA.get_n_slices();
arma_debug_assert_same_size(n_rows, n_cols, n_slices, PB.get_n_rows(), PB.get_n_cols(), PB.get_n_slices(), "max(): given cubes must have the same size");
out.set_size(n_rows, n_cols, n_slices);
eT* out_mem = out.memptr();
if( (ProxyCube<T1>::use_at == false) && (ProxyCube<T2>::use_at == false) )
{
typename ProxyCube<T1>::ea_type A = PA.get_ea();
typename ProxyCube<T2>::ea_type B = PB.get_ea();
const uword N = PA.get_n_elem();
for(uword i=0; i<N; ++i)
{
const eT A_val = A[i];
const eT B_val = B[i];
out_mem[i] = ( std::abs(A_val) > std::abs(B_val) ) ? A_val : B_val;
}
}
else
{
for(uword slice=0; slice < n_slices; ++slice)
for(uword col=0; col < n_cols; ++col )
for(uword row=0; row < n_rows; ++row )
{
const eT A_val = PA.at(row,col,slice);
const eT B_val = PB.at(row,col,slice);
*out_mem = ( std::abs(A_val) > std::abs(B_val) ) ? A_val : B_val;
++out_mem;
}
}
}
示例6: P
inline
arma_warn_unused
uword
BaseCube<elem_type,derived>::index_min() const
{
const ProxyCube<derived> P( (*this).get_ref() );
uword index = 0;
if(P.get_n_elem() == 0)
{
arma_debug_check(true, "index_min(): object has no elements");
}
else
{
op_min::min_with_index(P, index);
}
return index;
}
示例7: P
inline
void
op_real::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_real>& X )
{
arma_extra_debug_sigprint();
typedef typename T1::pod_type T;
const ProxyCube<T1> P(X.m);
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
const uword n_slices = P.get_n_slices();
out.set_size(n_rows, n_cols, n_slices);
T* out_mem = out.memptr();
if(ProxyCube<T1>::prefer_at_accessor == false)
{
typedef typename ProxyCube<T1>::ea_type ea_type;
const uword n_elem = P.get_n_elem();
ea_type A = P.get_ea();
for(uword i=0; i < n_elem; ++i)
{
out_mem[i] = std::real( A[i] );
}
}
else
{
for(uword slice=0; slice < n_slices; ++slice)
for(uword col=0; col < n_cols; ++col )
for(uword row=0; row < n_rows; ++row )
{
*out_mem = std::real( P.at(row,col,slice) );
out_mem++;
}
}
}
示例8:
inline
void
glue_min::apply(Cube<eT>& out, const ProxyCube<T1>& PA, const ProxyCube<T2>& PB)
{
arma_extra_debug_sigprint();
const uword n_rows = PA.get_n_rows();
const uword n_cols = PA.get_n_cols();
const uword n_slices = PA.get_n_slices();
arma_debug_assert_same_size(n_rows, n_cols, n_slices, PB.get_n_rows(), PB.get_n_cols(), PB.get_n_slices(), "min(): given cubes must have the same size");
out.set_size(n_rows, n_cols, n_slices);
eT* out_mem = out.memptr();
if( (ProxyCube<T1>::use_at == false) && (ProxyCube<T2>::use_at == false) )
{
typename ProxyCube<T1>::ea_type A = PA.get_ea();
typename ProxyCube<T2>::ea_type B = PB.get_ea();
const uword N = PA.get_n_elem();
for(uword i=0; i<N; ++i)
{
out_mem[i] = (std::min)(A[i], B[i]);
}
}
else
{
for(uword slice=0; slice < n_slices; ++slice)
for(uword col=0; col < n_cols; ++col )
for(uword row=0; row < n_rows; ++row )
{
*out_mem = (std::min)( PA.at(row,col,slice), PB.at(row,col,slice) );
++out_mem;
}
}
}
示例9: P
inline
typename arma_not_cx<typename T1::elem_type>::result
op_min::min(const BaseCube<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const ProxyCube<T1> P(X.get_ref());
const uword n_elem = P.get_n_elem();
if(n_elem == 0)
{
arma_debug_check(true, "min(): object has no elements");
return Datum<eT>::nan;
}
eT min_val = priv::most_pos<eT>();
if(ProxyCube<T1>::use_at == false)
{
typedef typename ProxyCube<T1>::ea_type ea_type;
ea_type A = P.get_ea();
uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
const eT tmp_i = A[i];
const eT tmp_j = A[j];
if(tmp_i < min_val) { min_val = tmp_i; }
if(tmp_j < min_val) { min_val = tmp_j; }
}
if(i < n_elem)
{
const eT tmp_i = A[i];
if(tmp_i < min_val) { min_val = tmp_i; }
}
}
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
const uword n_slices = P.get_n_slices();
for(uword slice=0; slice < n_slices; ++slice)
for(uword col=0; col < n_cols; ++col )
for(uword row=0; row < n_rows; ++row )
{
const eT tmp = P.at(row,col,slice);
if(tmp < min_val) { min_val = tmp; }
}
}
return min_val;
}