#include "VectorCpx.h"
#include <fstream>
using namespace std;
fstream file("outVec.txt", ios::out);
void outVec(const VectorCpx& v){
file << "Size: " << v.size() << ", Capacity: " << v.capacity() << endl;
file << v;
}
int main(){
VectorCpx v1;
VectorCpx v2(5, Complex(1.234, 5.678));
VectorCpx v3 = v2;
file << "--------- A --------" << endl;
file << v1 << v2 << v3;
v2[2].real(9.87);
v3[-1].real(0);
v3[100].imag(999);
file << "--------- B --------" << endl;
outVec(v1); outVec(v2); outVec(v3);
file << "v2*v3=" << v2 * v3 << endl;
v1.resize(10);
v2.resize(8, Complex(0.1, 0.5));
v3.resize(3);
file << "--------- C --------" << endl;
outVec(v1); outVec(v2); outVec(v3);
file << "v2*v3=" << v2 * v3 << endl;
v1.resize(2);
v3 = v1;
file << "--------- D --------" << endl;
outVec(v1); outVec(v2); outVec(v3);
v3[0] = v2[0];
v3[1] = v2[2];
v2.push_back(Complex(0.8051, 0.9801));
v3.push_back(Complex(0.5566, 0.9527)); //這裡很謎,如果寫v3.push_back(Complex(0.5566, 0.9527)).push_back(Complex(0.2, 0.3))會讀不到後面那個,拆開卻沒事
v3.push_back(Complex(0.2, 0.3));
file << "--------- E --------" << endl;
outVec(v1); outVec(v2); outVec(v3);
file << "v2*v3=" << v2 * v3 << endl;
v1 = v3 * Complex(2.0);
v2 = Complex(3.0, 4.0) * v3;
file << "--------- F --------" << endl;
outVec(v1); outVec(v2); outVec(v3);
file.close();
}
I2luY2x1ZGUgIlZlY3RvckNweC5oIgojaW5jbHVkZSA8ZnN0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmZzdHJlYW0gZmlsZSgib3V0VmVjLnR4dCIsIGlvczo6b3V0KTsKCnZvaWQgb3V0VmVjKGNvbnN0IFZlY3RvckNweCYgdil7CiAgICBmaWxlIDw8ICJTaXplOiAiIDw8IHYuc2l6ZSgpIDw8ICIsIENhcGFjaXR5OiAiIDw8IHYuY2FwYWNpdHkoKSA8PCBlbmRsOwogICAgZmlsZSA8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