Hi everyone:
I'm having problems constructing a loop and I'd appreciate any advice. This is probably a simple problem, but I just can't make it work! This isn't homework! I'm an old fart and I'm new to C++.
Here's what I want to do: take a vector and insert it as the column of a matrix.
Here's the problem: I have no problem doing this for a vector that has the same number of rows as the matrix. My problem is that the matrix contains extra rows. What I am having trouble doing is constructing a loop that puts the elements of the vector in the right rows of the matrix.
Specifically, I have not been able to construct a loop that divides my vector into three parts, then puts each part in the matrix with two empty matrix rows separating it from the next vector part. It would be great if someone could provide a simple example.
For example:
1) numRowsVector is the number of rows in the vector. Let's say it's 9.
numRowsMatrix is the number of rows in the matrix. It's 25.
2) numRowsVector needs to be divided into 3 parts (always--regardless of the number of elements it contains).
3) Then the first part of the vector needs to be put into the first column of the matrix. The first element of the vector should appear in matrix row = numRowsVector + 3 (indexing starts at 0):
E.g.,
numRowsMatrix [numRowsVector + 3] [1] = numRowsVector[0]
4) There should be two empty rows in the matrix that separate the first vector part from the second vector part. Then there should be two empty rows in the matrix that separate the second and third vector parts. Then the last rows of the matrix should be empty (the number of empty rows = numRowsVector + 2).
More detail: yesterday Fbody here at Daniweb kindly informed me that it is possible to use two iterators in one for loop. This solved one problem. But after trying many different things, I'm still stuck. Rather than post them all, I'm hoping that someone might be willing to post a simple example that will set me straight. Thank you.