⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vnl_matrix_update.h

📁 DTMK软件开发包,此为开源软件,是一款很好的医学图像开发资源.
💻 H
字号:
// This is core/vnl/algo/vnl_matrix_update.h
#ifndef vnl_matrix_update_h_
#define vnl_matrix_update_h_

//:
// \file
// \brief Function to compute M=M+a*b'
// \author  Tim Cootes

#include <vnl/vnl_vector.h>
#include <vnl/vnl_matrix.h>
#include <vcl_cassert.h>

//: Perform rank 1 update of M:   M+=(a*b')
//  Requires a.size()==M.rows(),  b.size()==M.columns()
template<class T>
inline void vnl_matrix_update(vnl_matrix<T>& M,
                              const vnl_vector<T>& a,
                              const vnl_vector<T>& b)
{
  unsigned nr=M.rows();
  unsigned nc=M.columns();
  assert(a.size()==nr);
  assert(b.size()==nc);
  T** rows=M.data_array();
  for (unsigned i=0;i<nr;++i)
  {
    // Update row i of M
    double ai = a[i];
    T* row= rows[i]-1;
    const T* b_data=b.data_block()-1;
    // Fast loop through elements in row
    for (unsigned j=nc;j;--j) row[j] += ai*b_data[j];
  }
}

#endif // vnl_matrix_update_h_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -