Message Boards Message Boards

Sparse matrices with named rows and columns

Posted 9 years ago
POSTED BY: Anton Antonov
6 Replies
Posted 9 years ago

Anton, This looks potentially useful. However, when I tried to load it, I got a

Needs::nocont: Context RSparseMatrix` was not created when Needs was evaluated. >>

error. When I then tried importing it, it imported OK, but some of the functions did not work.

POSTED BY: Vilis Nams

What commands did you use? I have no problem loading the file with Import. The package is under development so it is not a real Mathematica package.

Please try these commands:

Import["https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/Misc/RSparseMatrix.m"]
rmat = MakeRSparseMatrix[SparseArray[RandomReal[{0, 1}, {4, 5}]]]
SetRowNames[rmat, Characters["ABCD"]]
SetColumnNames[rmat, Characters["abcde"]]
MatrixForm[rmat]

You should get something like this:

enter image description here

Further, commands like this:

MatrixForm[rmat[[{"A", "D", "C", "B"}]].Transpose[rmat]]

seem to work:

enter image description here

POSTED BY: Anton Antonov
Posted 9 years ago

Anton, I'm very embarrassed. Before Importing it, I had tried loading it by Needs and by Get. Then after that the Import didn't work. But now when I try Import initially, it works fine.

POSTED BY: Vilis Nams

Great then. Thanks for using this package!

POSTED BY: Anton Antonov

Very useful, Anton, thanks for sharing, I added this post to a few useful groups including Mathematica Add-Ons. Have you hears of PackageData.net? - A good place to mention it too.

POSTED BY: Vitaliy Kaurov

Thanks for proclaiming this package in Mathematica Add-Ons, Vitaliy! I will remember your advice to use the forums / groups you mentioned.

POSTED BY: Anton Antonov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract