Hey hey,
I've come up against a challange I can't solve. I have an opcode with a 2d array parameter, internally a slightly transformed version of that matrix shall be stored. Updates only occur when the input parameter changes. the idea is:
init interla matrix from parameter matrix
if parameter matrix has changed
update at k-rate
The code construct for the initialisation appears to fail.
The parameter handed to the opcode is known as
kRoutes
The internal matrix is called:
kMatrix
the first dimension is iterated through with iIndIns, the second dimension with iIndOuts. iIndInsWrite is the actual position in kMatrix where something will be written.
Consider this piece of code, Itried variants...
iIndOuts = 0
while (iIndOuts < iLenOuts) do
iIndIns = 0 ; reset pointer to kRoutes
iIndInsWrite = 0 ; reset pointer to kMatrix
while (iIndIns < iLenIns) do
if (kRoutes[iIndIns][iIndOuts] == 1 ) then ; This fails, I think!
kMatrix[iIndInsWrite][iIndOuts] = iIndIns
iIndInsWrite += 1
endif
iIndIns += 1
od
; Fill the rest of the column
while (iIndInsWrite < iLenIns) do
kMatrix[iIndInsWrite][iIndOuts] = -1
iIndInsWrite += 1
od
iIndOuts += 1
od
Instead of if (kRoutes[... I also tried if (i(kRoutes, ...)
I also tried using:
kMatrix[iIndInsWrite][iIndOuts] init iIndIns
So exchanging init for '='.
The best I could get with using init for assignment to matrix was a
matrix of -1. Otherwise I get a matrix of 0.
does anyone have an idea how to properly code/structure this use-case?
Or does anyone know which point I missed?
Hi Joachim,
my application is a matrix mixer. I get in a full matrix, with a 1 at each point where a connection is made and try to condense the number of multiplications and additions by having another matrix which only contains the necessary indices to focus on. For that I have to initialise this "condensed" internal matrix. The internal matrix contains the array indices that are relevant and -1 after that. Example. The connections matrix looks like this:
out1 out2
0 1 in1
1 0 in2
this condesned matrix:
out1 out2
1 0 in1
-1 -1 in2
So in the real multiplications that happen every k-cycle, I will loop:
while index2 < cols
while index1 < rows
if kmatrix[index1][index2] == -1
index1 = huge!
index1++
index2++
I update the internal kmatrix whenver something changes in the real connections matrix at k-rate,but I have to initialise it once. the idea is: in your average matrx mixer out of n times n i/o combinations you will only use a fraction and thus it is good sense to optimised the looping and multiplication and addition operations.
Does that make more sense?
In the end it comes down to operations like:
aOut[IndexOut] = aOut[IndexOut] + aIn[Indexin] * kLevel[IndexIn]
If the inner IndexIn loop can be be shortened to the actual number of inputs summed into the output that is a great help. That expression is simplified, I actually take the IndexIn from the condensed kMatrix. Thus it's a twofold process.