# Store matrices in dictionary

hey, i was trying to store these feedback matrices in a dictionary with:

``````matrices.do{|matrix, i|
};
``````

Is there a method for getting the name of the array so it could be used as a key inside the dictionary?
so i could use the dictionary like this: `~fbMatrixDict[\householder];`
instead of: `~fbMatrixDict[\0];`

Ive looked at the helpfile of Array and couldnt find it.

``````(

householder = [
[ -1.0, 1.0, 1.0, 1.0 ],
[ 1.0, -1.0, 1.0, 1.0 ],
[ 1.0, 1.0, -1.0, 1.0 ],
[ 1.0, 1.0, 1.0, -1.0 ]
]  * 0.5;

puckette = [
[0, 1, 1, 0],
[-1, 0, 0, -1],
[1, 0, 0, -1],
[0, 1, -1, 0]
]  * sqrt(2).reciprocal;

[ 1,  1,  1,  1 ],
[ 1, -1,  1, -1 ],
[ 1,  1, -1, -1 ],
[ 1, -1, -1,  1 ],
]  * ( sqrt(2).reciprocal * sqrt(2).reciprocal );

[ 1,  1,  1,  1,  1,  1,  1,  1 ],
[ 1, -1,  1, -1,  1, -1,  1, -1 ],
[ 1,  1, -1, -1,  1,  1, -1, -1 ],
[ 1, -1, -1,  1,  1, -1, -1,  1 ],
[ 1,  1,  1,  1, -1, -1, -1, -1 ],
[ 1, -1,  1, -1, -1,  1, -1,  1 ],
[ 1,  1, -1, -1, -1, -1,  1,  1 ],
[ 1, -1, -1,  1, -1,  1,  1, -1 ],
]  * ( sqrt(2).reciprocal * sqrt(2).reciprocal * sqrt(2).reciprocal );

[ 1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1],
[ 1,  -1,   1,  -1,   1,  -1,   1,  -1,   1,  -1,   1,  -1,   1,  -1,   1,  -1],
[ 1,   1,  -1,  -1,   1,   1,  -1,  -1,   1,   1,  -1,  -1,   1,   1,  -1,  -1],
[ 1,  -1,  -1,   1,   1,  -1,  -1,   1,   1,  -1,  -1,   1,   1,  -1,  -1,   1],
[ 1,   1,   1,   1,  -1,  -1,  -1,  -1,   1,   1,   1,   1,  -1,  -1,  -1,  -1],
[ 1,  -1,   1,  -1,  -1,   1,  -1,   1,   1,  -1,   1,  -1,  -1,   1,  -1,   1],
[ 1,   1,  -1,  -1,  -1,  -1,   1,   1,   1,   1,  -1,  -1,  -1,  -1,   1,   1],
[ 1,  -1,  -1,   1,  -1,   1,   1,  -1,   1,  -1,  -1,   1,  -1,   1,   1,  -1],
[ 1,   1,   1,   1,   1,   1,   1,   1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1],
[ 1,  -1,   1,  -1,   1,  -1,   1,  -1,  -1,   1,  -1,   1,  -1,   1,  -1,   1],
[ 1,   1,  -1,  -1,   1,   1,  -1,  -1,  -1,  -1,   1,   1,  -1,  -1,   1,   1],
[ 1,  -1,  -1,   1,   1,  -1,  -1,   1,  -1,   1,   1,  -1,  -1,   1,   1,  -1],
[ 1,   1,   1,   1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   1,   1,   1,   1],
[ 1,  -1,   1,  -1,  -1,   1,  -1,   1,  -1,   1,  -1,   1,   1,  -1,   1,  -1],
[ 1,   1,  -1,  -1,  -1,  -1,   1,   1,  -1,  -1,   1,   1,   1,   1,  -1,  -1],
[ 1,  -1,  -1,   1,  -1,   1,   1,  -1,  -1,   1,   1,  -1,   1,  -1,  -1,   1],
] * ( sqrt(2).reciprocal * sqrt(2).reciprocal * sqrt(2).reciprocal * sqrt(2).reciprocal );

~fbMatrixDict = Dictionary.new;

/*
*/

matrices.do{|matrix, i|
};
)

~fbMatrixDict[\4];

~fbMatrixDict[\householder];
~fbMatrixDict[\puckette];

~fbMatrixDict.clear;
``````

Arrays don’t have names.

You’re storing them in variables, but the variable name is not a property of the array. So there is no way to ask an array what its name is.

hjh

thank you. is there another good solution?

Why not directly store it in a dictionary?

``````(
// make a library of matrices
var matlib = ();
matlib[\myspecialmatrix] = [[1, 0], [0,1]];
matlib[\anotherone] =  [ [1,0,0], [0,1,0], [0,0,1]] * sqrt(2).reciprocal;

// use one
matlib[\anotherone].postln;
)
``````

yes of course
ive been thinking way too complicated.
thanks a lot