|
[Sponsors] |
June 16, 2010, 11:15 |
Vector Declaration
|
#1 |
Member
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 15 |
Hi,
I'm trying to declare a vector list inside a for loop while reading vectors from another list. Here is the for loop. I'm getting an error on the vector delcaration. for(int c=0; c<turbNum ;c++) { List<List<vector> > nacHubGrd[c,0]=nacLocation[c]; Info<<nacHubGrd<<endl; } Apparently I need to declare the size of the List. I'm not sure how to do this. I appreciate any help! Thanks! Last edited by tonyuprm; June 16, 2010 at 12:41. Reason: more info |
|
June 17, 2010, 02:49 |
|
#2 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 17 |
Hi Tony,
you have to declare and initialize your field before accessing single columns. A vectorListList of size nxm can be declared and initialized zero as follows: Code:
List<List<vector> > nacHubGrd (n, List<vector>(m, vector::zero)) Code:
nacHubGrad[i][j] //one single vector nacHubGrad[i] // one of the vectorLists Stefan |
|
June 17, 2010, 11:27 |
|
#3 |
Member
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 15 |
Thanks a lot Stefan, that worked perfectly!
ok, now it's getting a little bit more complicated and I need to do another list. Im trying: List<List<List<vector> > > bladePoints (turbNum,bladeNum, List<vector>(3, vector::zero)); but its not working, Any suggestions? Thanks! Last edited by tonyuprm; June 17, 2010 at 13:44. |
|
June 18, 2010, 08:21 |
|
#4 |
Senior Member
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 17 |
It's proof by induction! Actually, it is just a simple extension of Stefan's example, but maybe formatting it a little differently will help you to understand:
Code:
label l(2),m(3),n(4); List<List<List<vector> > > bladePoints ( l, List<List<vector> > ( m, List<vector> ( n, vector::zero ) ) );
__________________
David A. Boger |
|
June 21, 2010, 12:17 |
|
#5 |
Member
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 15 |
Thanks David!
|
|
|
|