本文整理汇总了C++中Proxy::get_n_cols方法的典型用法代码示例。如果您正苦于以下问题:C++ Proxy::get_n_cols方法的具体用法?C++ Proxy::get_n_cols怎么用?C++ Proxy::get_n_cols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Proxy
的用法示例。
在下文中一共展示了Proxy::get_n_cols方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: P
inline
bool
op_sqrtmat::apply_direct(Mat< std::complex<typename T1::elem_type> >& out, const Base<typename T1::elem_type,T1>& expr)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type in_T;
typedef typename std::complex<in_T> out_T;
const Proxy<T1> P(expr.get_ref());
arma_debug_check( (P.get_n_rows() != P.get_n_cols()), "sqrtmat(): given matrix must be square sized" );
if(P.get_n_elem() == 0)
{
out.reset();
return true;
}
typename Proxy<T1>::ea_type Pea = P.get_ea();
Mat<out_T> U;
Mat<out_T> S(P.get_n_rows(), P.get_n_cols());
out_T* Smem = S.memptr();
const uword N = P.get_n_elem();
for(uword i=0; i<N; ++i)
{
Smem[i] = std::complex<in_T>( Pea[i] );
}
const bool schur_ok = auxlib::schur(U,S);
if(schur_ok == false)
{
arma_extra_debug_print("sqrtmat(): schur decomposition failed");
out.reset();
return false;
}
const bool status = op_sqrtmat_cx::helper(S);
const Mat<out_T> X = U*S;
S.reset();
out = X*U.t();
return status;
}
示例2: pa
inline
arma_warn_unused
typename
enable_if2
<(is_arma_type<T1>::value) && (is_arma_sparse_type<T2>::value) && (is_same_type<typename T1::elem_type, typename T2::elem_type>::value),
typename T1::elem_type
>::result
dot
(
const Base<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const Proxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_rows(), pb.get_n_cols(), "dot()");
typedef typename T1::elem_type eT;
eT result = eT(0);
typename SpProxy<T2>::const_iterator_type it = pb.begin();
// prefer_at_accessor won't save us operations
while(it.pos() < pb.get_n_nonzero())
{
result += (*it) * pa.at(it.row(), it.col());
++it;
}
return result;
}
示例3: A
inline
void
glue_mixed_plus::apply(Mat<typename eT_promoter<T1,T2>::eT>& out, const mtGlue<typename eT_promoter<T1,T2>::eT, T1, T2, glue_mixed_plus>& 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 Proxy<T1> A(X.A);
const Proxy<T2> B(X.B);
arma_debug_assert_same_size(A, B, "matrix addition");
out.set_size(A.get_n_rows(), A.get_n_cols());
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: A
inline
void
glue_cross::apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_cross>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
typedef typename Proxy<T1>::ea_type ea_type1;
typedef typename Proxy<T2>::ea_type ea_type2;
const Proxy<T1> A(X.A);
const Proxy<T2> B(X.B);
arma_debug_check( ((A.get_n_elem() != 3) || (B.get_n_elem() != 3)), "cross(): input vectors must have 3 elements" );
out.set_size(A.get_n_rows(), A.get_n_cols());
eT* out_mem = out.memptr();
ea_type1 PA = A.get_ea();
ea_type2 PB = B.get_ea();
const eT ax = PA[0];
const eT ay = PA[1];
const eT az = PA[2];
const eT bx = PB[0];
const eT by = PB[1];
const eT bz = PB[2];
out_mem[0] = ay*bz - az*by;
out_mem[1] = az*bx - ax*bz;
out_mem[2] = ax*by - ay*bx;
}
示例5:
arma_hot
inline
void
op_fft_cx::copy_vec_proxy(typename Proxy<T1>::elem_type* dest, const Proxy<T1>& P, const uword N)
{
arma_extra_debug_sigprint();
if(Proxy<T1>::use_at == false)
{
typename Proxy<T1>::ea_type X = P.get_ea();
for(uword i=0; i < N; ++i) { dest[i] = X[i]; }
}
else
{
if(P.get_n_cols() == 1)
{
for(uword i=0; i < N; ++i) { dest[i] = P.at(i,0); }
}
else
{
for(uword i=0; i < N; ++i) { dest[i] = P.at(0,i); }
}
}
}
示例6: eT
arma_hot
inline
typename T1::elem_type
accu_proxy_at(const Proxy<T1>& P)
{
typedef typename T1::elem_type eT;
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
eT val = eT(0);
if(n_rows != 1)
{
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
val += P.at(row,col);
}
}
else
{
for(uword col=0; col < n_cols; ++col)
{
val += P.at(0,col);
}
}
return val;
}
示例7: P
inline
bool
op_any::any_vec_helper(const Base<typename T1::elem_type, T1>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const Proxy<T1> P(X.get_ref());
const uword n_elem = P.get_n_elem();
if(Proxy<T1>::prefer_at_accessor == false)
{
typename Proxy<T1>::ea_type Pea = P.get_ea();
for(uword i=0; i<n_elem; ++i)
{
if(Pea[i] != eT(0)) { return true; }
}
}
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
if(P.at(row,col) != eT(0)) { return true; }
}
}
return false;
}
示例8:
arma_hot
inline
void
arma_assert_same_size(const Proxy<eT1>& A, const Proxy<eT2>& B, const char* x)
{
const uword A_n_rows = A.get_n_rows();
const uword A_n_cols = A.get_n_cols();
const uword B_n_rows = B.get_n_rows();
const uword B_n_cols = B.get_n_cols();
if( (A_n_rows != B_n_rows) || (A_n_cols != B_n_cols) )
{
arma_stop( arma_incompat_size_string(A_n_rows, A_n_cols, B_n_rows, B_n_cols, x) );
}
}
示例9: P
arma_warn_unused
inline
typename T1::elem_type
det
(
const Op<T1, op_trimat>& X
)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const Proxy<T1> P(X.m);
const uword N = P.get_n_rows();
arma_debug_check( (N != P.get_n_cols()), "det(): given matrix must be square sized" );
eT val1 = eT(1);
eT val2 = eT(1);
uword i,j;
for(i=0, j=1; j<N; i+=2, j+=2)
{
val1 *= P.at(i,i);
val2 *= P.at(j,j);
}
if(i < N)
{
val1 *= P.at(i,i);
}
return val1 * val2;
}
示例10: U
inline
void
op_diagmat2::apply(Mat<typename T1::elem_type>& out, const Proxy<T1>& P, const uword row_offset, const uword col_offset)
{
arma_extra_debug_sigprint();
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
const uword n_elem = P.get_n_elem();
if(n_elem == 0) { out.reset(); return; }
const bool P_is_vec = (T1::is_row) || (T1::is_col) || (n_rows == 1) || (n_cols == 1);
if(P_is_vec)
{
const uword n_pad = (std::max)(row_offset, col_offset);
out.zeros(n_elem + n_pad, n_elem + n_pad);
if(Proxy<T1>::prefer_at_accessor == false)
{
typename Proxy<T1>::ea_type Pea = P.get_ea();
for(uword i=0; i < n_elem; ++i)
{
out.at(row_offset + i, col_offset + i) = Pea[i];
}
}
else
{
const unwrap<typename Proxy<T1>::stored_type> U(P.Q);
const Proxy<typename unwrap<typename Proxy<T1>::stored_type>::stored_type> PP(U.M);
op_diagmat2::apply(out, PP, row_offset, col_offset);
}
}
else // P represents a matrix
{
arma_debug_check
(
((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (col_offset >= n_cols)),
"diagmat(): requested diagonal out of bounds"
);
out.zeros(n_rows, n_cols);
const uword N = (std::min)(n_rows - row_offset, n_cols - col_offset);
for(uword i=0; i<N; ++i)
{
const uword row = i + row_offset;
const uword col = i + col_offset;
out.at(row,col) = P.at(row,col);
}
}
}
示例11:
inline
void
glue_max::apply(Mat< std::complex<T> >& out, const Proxy<T1>& PA, const Proxy<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();
arma_debug_assert_same_size(n_rows, n_cols, PB.get_n_rows(), PB.get_n_cols(), "max(): given matrices must have the same size");
out.set_size(n_rows, n_cols);
eT* out_mem = out.memptr();
if( (Proxy<T1>::use_at == false) && (Proxy<T2>::use_at == false) )
{
typename Proxy<T1>::ea_type A = PA.get_ea();
typename Proxy<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 col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
const eT A_val = PA.at(row,col);
const eT B_val = PB.at(row,col);
*out_mem = ( std::abs(A_val) > std::abs(B_val) ) ? A_val : B_val;
++out_mem;
}
}
}
示例12:
inline
void
op_clamp::apply_noalias(Mat<typename T1::elem_type>& out, const Proxy<T1>& P, const typename T1::elem_type min_val, const typename T1::elem_type max_val)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
out.set_size(n_rows, n_cols);
eT* out_mem = out.memptr();
if(Proxy<T1>::use_at == false)
{
const uword N = P.get_n_elem();
typename Proxy<T1>::ea_type A = P.get_ea();
uword j;
for(j=1; j<N; j+=2)
{
eT val_i = A[j-1];
eT val_j = A[j ];
val_i = (val_i < min_val) ? min_val : ((val_i > max_val) ? max_val : val_i);
val_j = (val_j < min_val) ? min_val : ((val_j > max_val) ? max_val : val_j);
(*out_mem) = val_i; out_mem++;
(*out_mem) = val_j; out_mem++;
}
const uword i = j-1;
if(i < N)
{
eT val_i = A[i];
val_i = (val_i < min_val) ? min_val : ((val_i > max_val) ? max_val : val_i);
(*out_mem) = val_i;
}
}
else
{
for(uword col=0; col<n_cols; ++col)
for(uword row=0; row<n_rows; ++row)
{
eT val = P.at(row,col);
val = (val < min_val) ? min_val : ((val > max_val) ? max_val : val);
(*out_mem) = val; out_mem++;
}
}
}
示例13: pow
arma_hot
inline
typename T1::pod_type
arma_vec_norm_k
(
const Proxy<T1>& P,
const int k
)
{
arma_extra_debug_sigprint();
typedef typename T1::pod_type T;
T acc = T(0);
if(Proxy<T1>::prefer_at_accessor == false)
{
typename Proxy<T1>::ea_type A = P.get_ea();
const uword N = P.get_n_elem();
uword i,j;
for(i=0, j=1; j<N; i+=2, j+=2)
{
acc += std::pow(std::abs(A[i]), k);
acc += std::pow(std::abs(A[j]), k);
}
if(i < N)
{
acc += std::pow(std::abs(A[i]), k);
}
}
else
{
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
if(n_rows != 1)
{
for(uword col=0; col < n_cols; ++col)
for(uword row=0; row < n_rows; ++row)
{
acc += std::pow(std::abs(P.at(row,col)), k);
}
}
else
{
for(uword col=0; col < n_cols; ++col)
{
acc += std::pow(std::abs(P.at(0,col)), k);
}
}
}
return std::pow(acc, T(1)/T(k));
}
示例14: pa
inline
typename
enable_if2
<
(is_arma_type<T1>::value && is_arma_sparse_type<T2>::value && is_same_type<typename T1::elem_type, typename T2::elem_type>::value),
Mat<typename T1::elem_type>
>::result
operator/
(
const Base<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const Proxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_rows(), pb.get_n_cols(), "element-wise division");
Mat<typename T1::elem_type> result(pa.get_n_rows(), pa.get_n_cols());
result.fill(Datum<typename T1::elem_type>::inf);
// Now divide each element
typename SpProxy<T2>::const_iterator_type it = pb.begin();
while(it.pos() < pb.get_n_nonzero())
{
if(Proxy<T1>::prefer_at_accessor == false)
{
const uword index = (it.col() * result.n_rows) + it.row();
result[index] = pa[index] / (*it);
}
else
{
result.at(it.row(), it.col()) = pa.at(it.row(), it.col()) / (*it);
}
++it;
}
return result;
}
示例15: A
inline
const Gen< Mat<typename T1::pod_type>, gen_zeros >
imag(const Base<typename T1::pod_type,T1>& X)
{
arma_extra_debug_sigprint();
const Proxy<T1> A(X.get_ref());
return Gen< Mat<typename T1::pod_type>, gen_zeros>(A.get_n_rows(), A.get_n_cols());
}