RE: Number of Rows/Columns of a Matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg37598] RE: [mg37572] Number of Rows/Columns of a Matrix
- From: "David Park" <djmp at earthlink.net>
- Date: Wed, 6 Nov 2002 06:53:26 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Matthias, I don't know where such functions are, but what is wrong with using Dimensions? You just have to add a check that you have a matrix. rows[mat_?MatrixQ] := First@Dimensions[mat] cols[mat_?MatrixQ] := Last@Dimensions[mat] Needs["LinearAlgebra`MatrixManipulation`"] mat = ZeroMatrix[Random[Integer, {1, 6}], Random[Integer, {1, 6}]] {rows[mat], cols[mat]} There are "Rows" and "Columns" specifications for GridBox creation, and Row and Column are option values in Table. These have nothing to do with your use. This touches on an issue of using Mathematica. Very often, it is necessary to write small routines or statements to provide facilities that are needed in one's work. It may seem that such routines should be provided as native routines in Mathematica but, in fact, there could be millions of such routines and then it would be difficult to find or name them anyway. Mathematica is somewhere between a toolkit for doing mathematics and a kit for making tools to do mathematics. Of course, if there is a Mathematica routine for something, it is probably better than most users can quickly produce so it makes sense to ask. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Matthias.Bode at oppenheim.de [mailto:Matthias.Bode at oppenheim.de] To: mathgroup at smc.vnet.net Dear Colleagues, I fail to locate the commands "Rows[mat]", "Columns[mat]" which give the number of rows and columns of a matrix; I believe they exist - and I do know Dimensions[]. Best regards, Matthias Bode Sal. Oppenheim jr. & Cie. KGaA Koenigsberger Strasse 29 D-60487 Frankfurt am Main GERMANY Tel.: +49(0)69 71 34 53 80 Mobile: +49(0)172 6 74 95 77 Fax: +49(0)69 71 34 95 380 E-mail: matthias.bode at oppenheim.de Internet: http://www.oppenheim.de