📄 potential.cpp
字号:
#include "Potential.h"#if 1Distribution operator*(const Distribution& dist, const Potential& potential){ Distribution ret(vector<double>(potential.dim2(), 0.0)); if (dist.dim() != potential.dim1()) { // DEBUG cout << "ERROR: dimension " << dist.dim() << " != " << potential.dim1() << endl; // TODO: throw an exception? return ret; } for (int j = 0; j < potential.dim2(); j++) { for (int i = 0; i < potential.dim1(); i++) { ret[j] += dist[i] * potential.get(i,j); } } return ret;}Distribution operator*(const Potential& potential, const Distribution& dist){ Distribution ret(vector<double>(potential.dim1(), 0.0)); if (dist.dim() != potential.dim2()) { // DEBUG cout << "ERROR: dimension " << dist.dim() << " != " << potential.dim2() << endl; return ret; } for (int i = 0; i < potential.dim1(); i++) { for (int j = 0; j < potential.dim2(); j++) { ret[i] += dist[j] * potential.get(i,j); } } return ret;}#endifostream& operator<<(ostream& out, const Potential& p){ out << "("; for (int i = 0; i < p.dim1(); i++) { if (i > 0) { out << " ; "; } for (int j = 0; j < p.dim2(); j++) { if (j > 0) { out << " "; } out << p.get(i,j); } } out << ")"; return out;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -