0

I have a 2x2 matrix A stored in data_

1 3 2 4 (column major order)

and a 2x2 matrix B stored in b.data_

5 7 6 8

and I'm using the function below to append (stick underneath) B to A.

so my result should be 1 3 5 7 2 4 6 8

however the result I'm getting is 1 3 0 0 2 4 6 8

so copy[2] and copy [3] are not getting calculated correctly yet I've worked it out on paper and it seems fine? Can anyone please spot what is wrong?

Thanks in advance!

```
void Matrix::AppendBelow(Matrix b)
{
vector<double> copy;
copy.resize (data_.size()+b.data_.size());
for (int i = 0; i < data_.size(); i++)
{
copy[i] = 0;
copy[i*mdim_ - (i % mdim_)] = data_[i];
copy[i*mdim_ + (((i+1) % mdim_) + 1)] = b.data_[i];
}
data_.resize (copy.size());
for (int k = 0; k < data_.size(); k++)
{
data_[k] = copy[k];
cout<<" "<<data_[k]<<" ";
}
}
```