本文整理汇总了C++中ProxyCube类的典型用法代码示例。如果您正苦于以下问题:C++ ProxyCube类的具体用法?C++ ProxyCube怎么用?C++ ProxyCube使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProxyCube类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arma_extra_debug_sigprint
inline
void
op_mean::apply(Cube<typename T1::elem_type>& out, const OpCube<T1,op_mean>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 2), "mean(): parameter 'dim' must be 0 or 1 or 2" );
const ProxyCube<T1> P(in.m);
if(P.is_alias(out) == false)
{
op_mean::apply_noalias(out, P, dim);
}
else
{
Cube<eT> tmp;
op_mean::apply_noalias(tmp, P, dim);
out.steal_mem(tmp);
}
}
示例2: arma_extra_debug_sigprint
inline
void
op_cx_scalar_div_post::apply
(
Cube< typename std::complex<typename T1::pod_type> >& out,
const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_post>& X
)
{
arma_extra_debug_sigprint();
typedef typename std::complex<typename T1::pod_type> eT;
const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const eT k = X.aux_out_eT;
const uword n_elem = out.n_elem;
eT* out_mem = out.memptr();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = A[i] / k;
}
}
示例3: arma_extra_debug_sigprint
inline
void
glue_mixed_schur::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const mtGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check();
const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise cube multiplication");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr();
const u32 n_elem = out.n_elem;
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) * upgrade_val<eT1,eT2>::apply(B[i]);
}
}
示例4: arma_extra_debug_sigprint
inline
void
glue_mixed_div::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const mtGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_div>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check();
const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise division");
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem;
// TODO: add faster handling of subviews
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A[i]) / upgrade_val<eT1,eT2>::apply(B[i]);
}
}
示例5: accu
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;
}
示例6: imag
inline
const GenCube<typename T1::pod_type, gen_zeros>
imag(const BaseCube<typename T1::pod_type,T1>& X)
{
arma_extra_debug_sigprint();
const ProxyCube<T1> A(X.get_ref());
return GenCube<typename T1::pod_type, gen_zeros>(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
}
示例7: size
arma_warn_unused
inline
uword
size(const BaseCube<typename T1::elem_type, T1>& X, const uword dim)
{
arma_extra_debug_sigprint();
const ProxyCube<T1> P(X.get_ref());
return SizeCube( P.get_n_rows(), P.get_n_cols(), P.get_n_slices() )( dim );
}
示例8: arma_extra_debug_sigprint
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;
}
}
}
示例9: accu
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;
}
}
示例10: arma_extra_debug_sigprint
inline
void
glue_mixed_schur::apply(Cube<typename eT_promoter<T1,T2>::eT>& out, const mtGlueCube<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_schur>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT1;
typedef typename T2::elem_type eT2;
typedef typename promote_type<eT1,eT2>::result out_eT;
promote_type<eT1,eT2>::check();
const ProxyCube<T1> A(X.A);
const ProxyCube<T2> B(X.B);
arma_debug_assert_same_size(A, B, "element-wise multiplication");
const uword n_rows = A.get_n_rows();
const uword n_cols = A.get_n_cols();
const uword n_slices = A.get_n_slices();
out.set_size(n_rows, n_cols, n_slices);
out_eT* out_mem = out.memptr();
const uword n_elem = out.n_elem;
const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
if(prefer_at_accessor == false)
{
typename ProxyCube<T1>::ea_type AA = A.get_ea();
typename ProxyCube<T2>::ea_type BB = B.get_ea();
for(uword i=0; i<n_elem; ++i)
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(AA[i]) * upgrade_val<eT1,eT2>::apply(BB[i]);
}
}
else
{
uword i = 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 )
{
out_mem[i] = upgrade_val<eT1,eT2>::apply(A.at(row,col,slice)) * upgrade_val<eT1,eT2>::apply(B.at(row,col,slice));
++i;
}
}
}
示例11: 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;
}
示例12: arma_extra_debug_sigprint
inline
void
op_imag::apply( Cube<typename T1::pod_type>& out, const mtOpCube<typename T1::pod_type, T1, op_imag>& X )
{
arma_extra_debug_sigprint();
typedef typename T1::pod_type T;
const ProxyCube<T1> A(X.m);
out.set_size(A.get_n_rows(), A.get_n_cols(), A.get_n_slices());
const u32 n_elem = out.n_elem;
T* out_mem = out.memptr();
for(u32 i=0; i<n_elem; ++i)
{
out_mem[i] = std::imag(A[i]);
}
}
示例13: arma_extra_debug_sigprint
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;
}
}
}
示例14: arma_extra_debug_sigprint
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++;
}
}
}
}
示例15: arma_extra_debug_sigprint
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;
}