Ho una matrice NumPy:Che tipo di array Python sarebbe? Esiste già in Python?
m = array([[4, 0, 9, 0],
[0, 7, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 5]])
Le 4 colonne di m sono etichettati:
c = array([ 10, 20, 30, 40])
voglio essere in grado di tagliare un oggetto o
tale che:
o.vals[0,:] = array([4, 9])
o.vals[1,:] = array([7,])
o.vals[2,:] = array([])
o.vals[3,:] = array([5])
o.cols[0,:] = array([10, 30])# the non-zero column labels from row 0
o.cols[1,:] = array([20,])
o.cols[2,:] = array([])
o.cols[3,:] = array([40])
Esiste un oggetto Python esistente che potrebbe permettermi di farlo?
Ho visto Scipy Sparse Matrices, ma non è proprio quello che sto cercando.
UN AGGIORNAMENTO il 17 agosto 2015: Ho avuto un gioco intorno con alcune idee e si avvicinò con questo, che è quasi lo stesso di quello che ho descritto la settimana scorsa:
https://github.com/jsphon/NumericalFunctions/blob/master/jagged_array/JaggedKeyValueArray.rst
https://github.com/jsphon/NumericalFunctions/blob/master/jagged_array/jagged_key_value_array.py