Question
How do I derive a function that would store non-zero elements of a lower triangular matrix into a sequence by row-order? Let's say I have
How do I derive a function that would store non-zero elements of a lower triangular matrix into a sequence by row-order?
Let's say I have an n x n matrix where n = 5.
I already have the max number of non-zero elements, which is determined by the formula:
How do I figure out the formula, k, or f(i,j) where i represents the row and j represents the column, that would assign matrix element a[i,j] to its appropriate position in an array by order of row?
ex. a formula that would take a21 in the matrix above and generate the number 5, as it is the fifth matrix element by row-order.
EDIT: I am looking for a non-code expression for this formula, i.e. a mathematical formula similar to f(i,j) = (i-1)+3j that would find out the array position for each one of the matrix indices.
a1o 0 0 0 a22 0 0 10 - 20 21 22 a30 a31 332 333 40 41 42 43 44Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started