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

📄 vector_test.cpp

📁 矩阵运算源码最新版本
💻 CPP
字号:
#include<boost/numeric/ublas/matrix.hpp>#include<boost/numeric/ublas/vector.hpp>#include<boost/numeric/ublas/io.hpp>#include<complex>#include <boost/numeric/linear_algebra/concepts.hpp>#include <boost/numeric/linear_algebra/vector_concepts.hpp>typedef double Type;namespace ublas = boost::numeric::ublas;typedef ublas::vector<Type> Vector;template <typename T>struct dot {  T operator() (const T& v, const T& w)  {    using std::conj;    T tmp= 0;    for (int i= 0; i < v.size(); i++)      tmp+= conj(v[i]) * w[i];    return tmp;  }};namespace math {  concept_map HilbertSpace< dot<double>, Vector>;}int main (int argc, char* argv[])  {  const int v_size= 10;  Vector v(v_size), w(v_size), x, y(v_size-1);  for (int i= 0; i < v_size; i++)    v[i]= 1.0, w[i]= 2.0;  for (int i= 0; i < v_size-1; i++)     y[i]= 3.0;  w+= v;  try {    x= v + y;  } catch (ublas::bad_argument) {    std::cout << "caught bad argument " << std::endl;  }  std::cout << "v " << v << std::endl;  std::cout << "w " << w << std::endl;  std::cout << "x " << x << std::endl;  return 0;}

⌨️ 快捷键说明

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