- #1
atrus_ovis
- 101
- 0
Homework Statement
I don't know if this has ties to linear algebra, so sorry in advance if I'm posting in a wrong section.
We have an n*n matrix A, n is an odd number, and "the matrix's sides are 0" meaning:
we'll call non-zero elements as 1's for now.1st line 1111...1111
2nd line 0111...1110
3rd line 0011...1100
...
...
n-2 00111..11100
(n-1) 01111...1110
n 1111...1111
the diagonals are intact.
For example for n=3, this would be the matrix
111
010
111
for n=5
11111
01110
00100
01110
11111
etc
Now, the problem states that all non-zero data are stored in a 1-D array row by row, B[N-1], where N-1 the total number of nonzero elements(array index starts at 0).
We are asked to a)find a formula to correlate a non-zero element's coordinates in A with its position (array index) in array B.
For example for n=3, for the matrix A:
abc
0d0
efg
B would be b=[a,b,c,d,e,f,g], each non-zero elemet's position in B 0,1...6 respectively, and each nonzero element's coordinates {0,0}{0,1}{0,2}{1,1}{2,0}{2,1}{2,2} respectively.
and b) find a formula for the number of non-zero elements in A.
Homework Equations
?
The Attempt at a Solution
I found b), as
[Sum {from 1 to (n div 2)} 4*n ] + n , where div is integer division
as for a), i am trying to find a relation between i,j values, and their position in B, by trial and error, with only error so far.Any ideas?