- #1

- 3,003

- 2

## Main Question or Discussion Point

I am confusing the heck out of myself here.

This is what I have

Square matrix that is M = 'm x m'

A column vector that is C = 'm x 1'

a smaller square matrix that is R ='r x r'

Here is what I am trying to accomplish; I usually do this by hand:

The entries of the column vector C are either 1 or 0. If the i

This leaves me with a 3 x 3 sub-matrix that is made up of the un-crossed out entries of M.

This sub-matrix is R. So I need to find a way to assign these values to R from M after crossing out rows and columns according to the entries of C.

I have already created a test to initialize a matrix R of the correct dimensions; it is now a matter of getting the entries in there.

Something like:

But I think I will need 2 more counter variables in addition to i and j so that if C(i,1)=0 the indices of R do not increment.

I am just a little lost now. Can I get a little help here?

This is what I have

Square matrix that is M = 'm x m'

A column vector that is C = 'm x 1'

a smaller square matrix that is R ='r x r'

Here is what I am trying to accomplish; I usually do this by hand:

The entries of the column vector C are either 1 or 0. If the i

^{th}entry in C is zero then I can "cross out" the i^{th}row AND column in M. For example, if M is 5 x 5 and the 2nd and 4th entries of C are 0, I draw a line through the 2nd and 4th row AND column of M.This leaves me with a 3 x 3 sub-matrix that is made up of the un-crossed out entries of M.

This sub-matrix is R. So I need to find a way to assign these values to R from M after crossing out rows and columns according to the entries of C.

I have already created a test to initialize a matrix R of the correct dimensions; it is now a matter of getting the entries in there.

Something like:

Code:

```
For i = 1 to M
For j = 1 to M
If C(i,1) = 1 Then {R[something,something] = M[Something,Something]
Next j
Next i
```

But I think I will need 2 more counter variables in addition to i and j so that if C(i,1)=0 the indices of R do not increment.

I am just a little lost now. Can I get a little help here?