矩阵和数组有什么区别?我知道矩阵是2维的,而数组是n维的。


回答 1:

这取决于上下文,基本上就是您所在的领域。

WhenIwasdoingmathematicsprofessionally,Ihardlyeverheardthewordarray.Abuddyteachinglinearalgebrasaidthathewouldexplainwhatamatrixwasbysayingthatitwasjustatwodimensionalarrayofnumbers.Isupposetocollegestudentsthetermarraymightseemmorefamiliar.Inmathematicsifonesaysmatrixusuallyoneisthinkingofamatrixasarepresentationofalineartransformation.Amatrixmayhaveitsrowsandcolumnsindexedbysetsotherthan{1,...,n}.Callingafunctionoftwocontinuousvariables,whichrepresentsalineartransformation,amatrixcomesoffasratherabstractwhenonefirstencountersit(butamathematicianwillthink,whynot?).Ontheotherhand,incombinatoricsitseemstobereasonablycommontotalkaboutmatriceswhicharenotintendedtorepresentlineartransformations.(Ifwehaveafiniteset[math]{c1,...,ck}[/math]ofcolors,amatrixwhoseentriesaretakenfromthissetofcolorsdoesntstandforalineartransformationbecausetheentriesarentscalars,butsuchmatricesareoftenenoughstudiedincombinatoricsanyway.)When I was doing mathematics professionally, I hardly ever heard the word “array”. A buddy teaching linear algebra said that he would explain what a matrix was by saying that it was just a two-dimensional array of numbers. I suppose to college students the term “array” might seem more familiar. In mathematics if one says “matrix” usually one is thinking of a matrix as a representation of a linear transformation. A matrix may have its rows and columns indexed by sets other than \{1,...,n\}. Calling a function of two continuous variables, which represents a linear transformation, a “matrix” comes off as rather abstract when one first encounters it (but a mathematician will think, “why not?”). On the other hand, in combinatorics it seems to be reasonably common to talk about matrices which are not intended to represent linear transformations. (If we have a finite set [math]\{c_1,...,c_k\}[/math] of colors, a matrix whose entries are taken from this set of colors doesn’t stand for a linear transformation because the entries aren’t scalars, but such matrices are often enough studied in combinatorics anyway.)

在软件工程中,数组是许多编程语言中使用的数据结构。我现在将二维数组称为矩阵,如果我使用它来表示线性变换,那么我的同事们通常从学校中学到足够的数学知识就可以知道这一点。软件工程师似乎通常已经学会了可以使用矩阵来表示旋转(例如视图的图形渲染)。由于我们的代码主要是C ++,因此我们不再像以前那样频繁地引用数组,因为C ++提供了一个动态分配的数组,称为“向量”(即使内容没有几何意义)。这些结构(无论是否动态分配)当然很常见。

如果您想知道使用哪个术语,我会使用经验法则:如果结构的目的是表示线性变换,则将其称为矩阵,否则将其称为数组。