当前位置: 首页>>代码示例>>C++>>正文


C++ Mat::memptr方法代码示例

本文整理汇总了C++中Mat::memptr方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat::memptr方法的具体用法?C++ Mat::memptr怎么用?C++ Mat::memptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mat的用法示例。


在下文中一共展示了Mat::memptr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: P

inline
void
op_nonzeros::apply_noalias(Mat<typename T1::elem_type>& out, const SpBase<typename T1::elem_type,T1>& X)
  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type eT;
  
  const SpProxy<T1> P(X.get_ref());
  
  const uword N = P.get_n_nonzero();
  
  out.set_size(N,1);
  
  if(N > 0)
    {
    if(is_SpMat<typename SpProxy<T1>::stored_type>::value)
      {
      const unwrap_spmat<typename SpProxy<T1>::stored_type> U(P.Q);
      
      arrayops::copy(out.memptr(), U.M.values, N);
      }
    else
      {
      eT* out_mem = out.memptr();
      
      typename SpProxy<T1>::const_iterator_type it = P.begin();
      
      for(uword i=0; i<N; ++i)  { out_mem[i] = (*it); ++it; }
      }
    }
  }
开发者ID:Aeryltic,项目名称:labirynth,代码行数:32,代码来源:op_nonzeros_meat.hpp

示例2: tmp

inline
void
op_stddev::apply(Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_stddev>& in)
  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type  in_eT;
  typedef typename T1::pod_type  out_eT;
  
  const unwrap_check_mixed<T1> tmp(in.m, out);
  const Mat<in_eT>&        X = tmp.M;
  
  const uword norm_type = in.aux_uword_a;
  const uword dim       = in.aux_uword_b;
  
  arma_debug_check( (norm_type > 1), "stddev(): incorrect usage. norm_type must be 0 or 1");
  arma_debug_check( (dim > 1),       "stddev(): incorrect usage. dim must be 0 or 1"      );
  
  const uword X_n_rows = X.n_rows;
  const uword X_n_cols = X.n_cols;
  
  if(dim == 0)
    {
    arma_extra_debug_print("op_stddev::apply(), dim = 0");

    arma_debug_check( (X_n_rows == 0), "stddev(): given object has zero rows" );
    
    out.set_size(1, X_n_cols);
    
    out_eT* out_mem = out.memptr();
    
    for(uword col=0; col<X_n_cols; ++col)
      {
      out_mem[col] = std::sqrt( op_var::direct_var( X.colptr(col), X_n_rows, norm_type ) );
      }
    }
  else
  if(dim == 1)
    {
    arma_extra_debug_print("op_stddev::apply(), dim = 1");
    
    arma_debug_check( (X_n_cols == 0), "stddev(): given object has zero columns" );

    out.set_size(X_n_rows, 1);
    
    podarray<in_eT> dat(X_n_cols);
    
    in_eT*  dat_mem = dat.memptr();
    out_eT* out_mem = out.memptr();
    
    for(uword row=0; row<X_n_rows; ++row)
      {
      dat.copy_row(X, row);
      
      out_mem[row] = std::sqrt( op_var::direct_var( dat_mem, X_n_cols, norm_type) );
      }
    }
  }
开发者ID:DatawaveMarineScience,项目名称:OpenSEA,代码行数:58,代码来源:op_stddev_meat.hpp

示例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++;
        }
      }
    }
  }
开发者ID:EmanueleCannizzaro,项目名称:armadillo,代码行数:58,代码来源:op_vectorise_meat.hpp

示例4: eT

inline
void
interp1_helper_nearest(const Mat<eT>& XG, const Mat<eT>& YG, const Mat<eT>& XI, Mat<eT>& YI, const eT extrap_val)
  {
  arma_extra_debug_sigprint();
  
  const eT XG_min = XG.min();
  const eT XG_max = XG.max();
  
  YI.copy_size(XI);
  
  const eT* XG_mem = XG.memptr();
  const eT* YG_mem = YG.memptr();
  const eT* XI_mem = XI.memptr();
        eT* YI_mem = YI.memptr();
  
  const uword NG = XG.n_elem;
  const uword NI = XI.n_elem;
  
  uword best_j = 0;
  
  for(uword i=0; i<NI; ++i)
    {
    eT best_err = Datum<eT>::inf;
    
    const eT XI_val = XI_mem[i];
    
    if((XI_val < XG_min) || (XI_val > XG_max))
      {
      YI_mem[i] = extrap_val;
      }
    else
      {
      // XG and XI are guaranteed to be sorted in ascending manner,
      // so start searching XG from last known optimum position 
      
      for(uword j=best_j; j<NG; ++j)
        {
        const eT tmp = XG_mem[j] - XI_val;
        const eT err = (tmp >= eT(0)) ? tmp : -tmp;
        
        if(err >= best_err)
          {
          // error is going up, so we have found the optimum position
          break;
          }
        else
          {
          best_err = err;
          best_j   = j;   // remember the optimum position
          }
        }
      
      YI_mem[i] = YG_mem[best_j];
      }
    }
  }
开发者ID:Aeryltic,项目名称:labirynth,代码行数:57,代码来源:fn_interp1.hpp

示例5:

inline
void
op_fliplr::apply_direct(Mat<eT>& out, const Mat<eT>& X)
  {
  arma_extra_debug_sigprint();
  
  const uword X_n_rows = X.n_rows;
  const uword X_n_cols = X.n_cols;
  
  const uword X_n_cols_m1 = X_n_cols - 1;
  
  if(&out != &X)
    {
    out.set_size(X_n_rows, X_n_cols);
    
    if(X_n_rows == 1)
      {
      const eT*   X_mem =   X.memptr();
            eT* out_mem = out.memptr();
      
      for(uword col=0; col < X_n_cols; ++col)
        {
        out_mem[X_n_cols_m1 - col] = X_mem[col];
        }
      }
    else
      {
      for(uword col=0; col < X_n_cols; ++col)
        {
        out.col(X_n_cols_m1 - col) = X.col(col);
        }
      }
    }
  else  // in-place operation
    {
    const uword N = X_n_cols / 2;
    
    if(X_n_rows == 1)
      {
      eT* out_mem = out.memptr();
      
      for(uword col=0; col < N; ++col)
        {
        std::swap(out_mem[X_n_cols_m1 - col], out_mem[col]);
        }
      }
    else
      {
      for(uword col=0; col < N; ++col)
        {
        out.swap_cols(X_n_cols_m1 - col, col);
        }
      }
    }
  }
开发者ID:RcppCore,项目名称:RcppArmadillo,代码行数:55,代码来源:op_flip_meat.hpp

示例6: eT

arma_hot
inline
void
op_sum::apply_noalias_proxy(Mat<typename T1::elem_type>& out, const Proxy<T1>& P, const uword dim)
  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type eT;
  
  const uword P_n_rows = P.get_n_rows();
  const uword P_n_cols = P.get_n_cols();
  
  if(dim == 0)
    {
    out.set_size(1, P_n_cols);
    
    eT* out_mem = out.memptr();
    
    for(uword col=0; col < P_n_cols; ++col)
      {
      eT val1 = eT(0);
      eT val2 = eT(0);
      
      uword i,j;
      for(i=0, j=1; j < P_n_rows; i+=2, j+=2)
        {
        val1 += P.at(i,col);
        val2 += P.at(j,col);
        }
      
      if(i < P_n_rows)
        {
        val1 += P.at(i,col);
        }
      
      out_mem[col] = (val1 + val2);
      }
    }
  else
    {
    out.zeros(P_n_rows, 1);
    
    eT* out_mem = out.memptr();
    
    for(uword col=0; col < P_n_cols; ++col)
    for(uword row=0; row < P_n_rows; ++row)
      {
      out_mem[row] += P.at(row,col);
      }
    }
  }
开发者ID:PsycoTodd,项目名称:Armadillo_OpenCV_XCode_Framework,代码行数:51,代码来源:op_sum_meat.hpp

示例7:

inline
void
op_min::apply_noalias(Mat<eT>& out, const Mat<eT>& X, const uword dim, const typename arma_not_cx<eT>::result* junk)
  {
  arma_extra_debug_sigprint();
  arma_ignore(junk);
  
  const uword X_n_rows = X.n_rows;
  const uword X_n_cols = X.n_cols;
  
  if(dim == 0)
    {
    arma_extra_debug_print("op_min::apply(): dim = 0");
    
    out.set_size((X_n_rows > 0) ? 1 : 0, X_n_cols);
    
    if(X_n_rows == 0)  { return; }
    
    eT* out_mem = out.memptr();
    
    for(uword col=0; col<X_n_cols; ++col)
      {
      out_mem[col] = op_min::direct_min( X.colptr(col), X_n_rows );
      }
    }
  else
  if(dim == 1)
    {
    arma_extra_debug_print("op_min::apply(): dim = 1");
    
    out.set_size(X_n_rows, (X_n_cols > 0) ? 1 : 0);
    
    if(X_n_cols == 0)  { return; }
    
    eT* out_mem = out.memptr();
    
    arrayops::copy(out_mem, X.colptr(0), X_n_rows);
    
    for(uword col=1; col<X_n_cols; ++col)
      {
      const eT* col_mem = X.colptr(col);
      
      for(uword row=0; row<X_n_rows; ++row)
        {
        const eT col_val = col_mem[row];
        
        if(col_val < out_mem[row])  { out_mem[row] = col_val; }
        }
      }
    }
  }
开发者ID:JD26,项目名称:ICE,代码行数:51,代码来源:op_min_meat.hpp

示例8: eT

inline
void
glue_cov::direct_cov(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const Mat< std::complex<T> >& B, const u32 norm_type)
  {
  arma_extra_debug_sigprint();

  typedef typename std::complex<T> eT;

  if(A.is_vec() && B.is_vec())
    { 
    arma_debug_check( (A.n_elem != B.n_elem), "cov(): the number of elements in A and B must match" );

    const eT* A_ptr = A.memptr();
    const eT* B_ptr = B.memptr();        

    eT A_acc   = eT(0);
    eT B_acc   = eT(0);
    eT out_acc = eT(0);

    const u32 N = A.n_elem;

    for(u32 i=0; i<N; ++i)
      {
      const eT A_tmp = A_ptr[i];
      const eT B_tmp = B_ptr[i];

      A_acc += A_tmp;
      B_acc += B_tmp;

      out_acc += std::conj(A_tmp) * B_tmp;
      }

    out_acc -= (std::conj(A_acc) * B_acc)/eT(N);

    const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);

    out.set_size(1,1);
    out[0] = out_acc/norm_val;
    }
  else
    {
    arma_debug_assert_same_size(A, B, "cov()");
  
    const u32 N = A.n_rows;
    const eT norm_val = (norm_type == 0) ? ( (N > 1) ? eT(N-1) : eT(1) ) : eT(N);
    
    out = trans(A) * B;                     // out = strans(conj(A)) * B;
    out -= (trans(sum(A)) * sum(B))/eT(N);  // out -= (strans(conj(sum(A))) * sum(B))/eT(N);
    out /= norm_val;
    }
  }
开发者ID:davetcoleman,项目名称:SimplexSolver,代码行数:51,代码来源:glue_cov_meat.hpp

示例9: tmp

inline
void
op_max::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_max>& in)
  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type eT;
  
  const unwrap_check<T1> tmp(in.m, out);
  const Mat<eT>& X     = tmp.M;
  
  const uword dim = in.aux_uword_a;
  arma_debug_check( (dim > 1), "max(): incorrect usage. dim must be 0 or 1");
  
  const uword X_n_rows = X.n_rows;
  const uword X_n_cols = X.n_cols;
  
  if(dim == 0)
    {
    arma_extra_debug_print("op_max::apply(), dim = 0");
    
    arma_debug_check( (X_n_rows == 0), "max(): given object has zero rows" );

    out.set_size(1, X_n_cols);
    
    eT* out_mem = out.memptr();
    
    for(uword col=0; col<X_n_cols; ++col)
      {
      out_mem[col] = op_max::direct_max( X.colptr(col), X_n_rows );
      }
    }
  else
  if(dim == 1)
    {
    arma_extra_debug_print("op_max::apply(), dim = 1");
    
    arma_debug_check( (X_n_cols == 0), "max(): given object has zero columns" );

    out.set_size(X_n_rows, 1);
    
    eT* out_mem = out.memptr();
    
    for(uword row=0; row<X_n_rows; ++row)
      {
      out_mem[row] = op_max::direct_max( X, row );
      }
    }
  }
开发者ID:ELEN4002-Lab-Project-2012,项目名称:ELEN4002-Lab-Project,代码行数:49,代码来源:op_max_meat.hpp

示例10: uword

inline
void
internal_regspace_default_delta
  (
  Mat<eT>& x,
  const typename Mat<eT>::pod_type start,
  const typename Mat<eT>::pod_type end
  )
  {
  arma_extra_debug_sigprint();
  
  typedef typename Mat<eT>::pod_type T;
  
  const bool ascend = (start <= end);
  
  const uword N = uword(1) + uword((ascend) ? (end-start) : (start-end));
  
  x.set_size(N);
  
  eT* x_mem = x.memptr();
  
  if(ascend)
    {
    for(uword i=0; i < N; ++i)  { x_mem[i] = eT(start + T(i)); }
    }
  else
    {
    for(uword i=0; i < N; ++i)  { x_mem[i] = eT(start - T(i)); }
    }
  }
开发者ID:EmanueleCannizzaro,项目名称:armadillo,代码行数:30,代码来源:fn_regspace.hpp

示例11: 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;
  }
开发者ID:ELEN4002-Lab-Project-2012,项目名称:ELEN4002-Lab-Project,代码行数:33,代码来源:glue_cross_meat.hpp

示例12: A

inline
void
op_cx_scalar_minus_pre::apply
  (
        Mat< typename std::complex<typename T1::pod_type> >& out,
  const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_pre>& X
  )
  {
  arma_extra_debug_sigprint();
  
  typedef typename std::complex<typename T1::pod_type> eT;
  typedef typename T1::pod_type                         T;
  
  const Proxy<T1> A(X.m);
  
  out.set_size(A.n_rows, A.n_cols);
  
  const u32 n_elem  = A.n_elem;
  const eT  k       = X.aux_out_eT;
        eT* out_mem = out.memptr();
  
  for(u32 i=0; i<n_elem; ++i)
    {
    out_mem[i] = k - A[i];
    }
  }
开发者ID:Caelita,项目名称:groupsac,代码行数:26,代码来源:op_cx_scalar_meat.hpp

示例13: A

inline
void
glue_rel_lteq::apply
  (
        Mat   <u32>& out,
  const mtGlue<u32, T1, T2, glue_rel_lteq>& X
  )
  {
  arma_extra_debug_sigprint();
  
  const Proxy<T1> A(X.A);
  const Proxy<T2> B(X.B);
  
  arma_debug_assert_same_size(A, B, "operator<=");
  
  out.set_size(A.n_rows, A.n_cols);
  
  const u32  n_elem  = A.n_elem;
        u32* out_mem = out.memptr();
  
  for(u32 i=0; i<n_elem; ++i)
    {
    out_mem[i] = (A[i] <= B[i]) ? u32(1) : u32(0);
    }
  
  }
开发者ID:Caelita,项目名称:groupsac,代码行数:26,代码来源:glue_relational_meat.hpp

示例14: tmp

inline
void
op_cumsum_vec::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_cumsum_vec>& in)
  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type eT;
  
  const unwrap<T1>   tmp(in.m);
  const Mat<eT>& X = tmp.M;
  
  const uword n_elem = X.n_elem;
  
  out.copy_size(X);
  
        eT* out_mem = out.memptr();
  const eT* X_mem   = X.memptr();
  
  eT acc = eT(0);
  
  for(uword i=0; i<n_elem; ++i)
    {
    acc += X_mem[i];
    
    out_mem[i] = acc;
    }
  }
开发者ID:ajtoravi,项目名称:Thesis_Code,代码行数:27,代码来源:op_cumsum_meat.hpp

示例15:

arma_hot
inline
void
eop_core<eop_type>::apply(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x)
  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type eT;
  
  // NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing;
  // size setting and alias checking is done by either the Mat contructor or operator=()
  
  const eT  k       = x.aux;
        eT* out_mem = out.memptr();
  
  if(Proxy<T1>::prefer_at_accessor == false)
    {
    const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_elem;
    
    //if(memory::is_aligned(out_mem))
    if( memory::is_aligned(out_mem) && ((Proxy<T1>::is_fixed) ? (x.get_n_elem() >= 32) : true) )
      {
      memory::mark_as_aligned(out_mem);
      
      if(x.P.is_aligned())
        {
        typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea();
        
        arma_applier_1a(=);
        }
      else
        {
开发者ID:DASLaboratories,项目名称:Armadillo,代码行数:32,代码来源:eop_core_meat.hpp


注:本文中的Mat::memptr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。