I did vector calculation like blow.
Here I just use 2 vector addition C =A1+A2
But, now I want to add many vecters like A1+A2+...+A35
Is there any simple method beside
( I don't want to type continuously like A1,A2,A3,A4.....A35)
ex)
void sum(vector<long double>& C,const vector<long double>& A0,const vector<long double>& A1,..........const vector<long double>& A35)
{
for(int i=0; i<3; i++) C =A0+A1+...A35;
}
sum(C,A[0],A[1]..........A[35]);
please help me.
Thanks
------------------vector addtion program C=A1+A2---------------
#include<iostream>
#include <vector>
using namespace std;
void sum(vector<long double>& C,const vector<long double>& A0,const vector<long double>& A1)
{
for(int i=0; i<3; i++) C =A0+A1;
}
int main()
{
vector< vector<long double> > A(2);
for(int i=0; i<2; i++)
{
A.resize(3);
}
vector<long double> C(3);
A[0][0]=0.111915570000000; A[0][1]=0.642849880000000; A[0][2]=0.928839650000000;
A[1][0]=0.406786090000000; A[1][1]=-0.557532060000000; A[1][2]=-0.403578550000000;
sum(C,A[0],A[1]);
cout << "C:" << endl;
for (int i=0;i<3;i++) cout << C << endl;
}
-----------------------------------------------------------------
results:
C:
0.518702
0.0853178
0.525261