{ "info": { "author": "William Song", "author_email": "songcwzjut@163.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Science/Research", "License :: Public Domain", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.4", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "=============\r\nIntroduction\r\n=============\r\n\r\nThis is my module about matrix operation. It imitates matlab grammar.\r\nIf you love matlab as well as python, then this is your choice.\r\nIt will be a good experience to operating matrices matlab-like.\r\n\r\nSugar: one can use single index to refer to the elements in a matrix. (see following examples)\r\n\r\n============\r\nOrganization\r\n============\r\n\r\nmymat:\r\n\r\n + mymat\r\n + matshow\r\n + matdemo\r\n + test_mat\r\n + linalg\r\n + denoise\r\n\r\n\r\n============\r\nFeature\r\n============\r\n \r\nCurrent Version: \r\n 1. fix some bugs. \r\n 2. Demonstrate Gauss elimination with tkinter.\r\n 3. Define LinearEquation class\r\n\r\n >>> import mymat.matdemo\r\n >>> mymat.matdemo.main()\r\n\r\nMain Feature(>0.1.x):\r\n 1. MyMat, PyMat is now the subclass of MatBase\r\n 2. improve some essential methods, fix some bugs\r\n 3. the index can be in reserved order, such as A[3:1:-1,1]\r\n 4. see numerical experiment in mat_demo (improved)\r\n 5. add more methods (introduced below) and A[is,js]=[] now is legal\r\n 6. fix some bugs, make the codes more robust\r\n \r\n finally, another improvement is that when create a matrix, we use following codes to set dtype (may temporarily)\r\n\r\n if data.dtype != np.complex128 and data.dtype != object:\r\n kwargs.setdefault('dtype', np.float64)\r\n\r\nMain Feature(0.0.x):\r\n 1. introduce operator | and & to concatenate matrices\r\n 2. in setitem, the index is allowed to be out of range as matlab with the help of update method (see below)\r\n 3. correct the codes of delete, improve the codes of many method\r\n 4. add poly/expm (Tylor approximation) method to calculate p(A) and e^A\r\n 5. add totex method, transforming a matrix to its tex-form\r\n 6. the default dtype of MyMat is float64(complex128 when it is complex), but the integer matrix is int32. so, don't forget to convert the dtype if neccessary. But this is temporary.\r\n\r\nGrammar\r\n=========\r\n\r\nbasic grammar\r\n---------------\r\n\r\nimport::\r\n\r\n >>> import mymat\r\n >>> A = mymat.MyMat([]) # use import mymat.pymat to import PyMat\r\n\r\noperators (Python left, Matlab right)::\r\n\r\n A*B := A*B (B*A := B*A)\r\n A/B := A/B == A*B.I (B/A := B/A == B*A.I)\r\n A ** B := A .* B (B ** A := B .* A)\r\n A//B := A./B (B//A := B./A)\r\n A<>> A=TestMat(5)\r\n [1, 2, 3, 4, 5;\r\n 6, 7, 8, 9, 10;\r\n 11, 12, 13, 14, 15;\r\n 16, 17, 18, 19, 20;\r\n 21, 22, 23, 24, 25]: M(5 X 5)\r\n >>> A[[3,4,7,10]] # with single index as in matlab\r\n [11, 16, 7, 22]: M(1 X 4)\r\n >>> A[[2,3],1:4]\r\n [6, 7, 8, 9;\r\n 11, 12, 13, 14]: M(2 X 4)\r\n >>> A[[1,3],[2,4]] # use A.get(([1,3],[2,4])) to get matrix([2, 14])\r\n [2, 4;\r\n 12, 14]: M(2 X 2)\r\n\r\n >>> A[3:1:-1,:] # reversing order\r\n [11, 12, 13, 14, 15;\r\n 6, 7, 8, 9, 10;\r\n 1, 2, 3, 4, 5]: M(3 X 5)\r\n\r\nUse delete method to delete some rows or columns, as in matlab::\r\n\r\n >>> A=H(7)\r\n >>> B=A.delete([1,3],slice(3)) # <=> B=A.copy(); B[[1,3],[1,2,3]]=[]\r\n >>> B.shape\r\n (5, 4)\r\n\r\nLinear equation::\r\n\r\n >>> le = LinearEquation(A, b)\r\n >>> print(le.totex()) # print tex of a linear equation\r\n\r\n\r\nDemonstration and Visualization\r\n---------------------------------\r\n\r\ndemonstration and numerical experiment::\r\n\r\n >>> import mymat\r\n >>> import mymat.matdemo # see Gauss elimination\r\n >>> A=mymat.MyMat('1,1,1,6;0,4,-1,5;2,-2,1,1') # or A=mymat.MyMat('1&1&1&6\\\\0&4&-1&5\\\\2&-2&1&1') just copying the latex codes\r\n >>> mymat.matdemo.guassDemo(A) # show the process of getting the echelon form of A\r\n >>> mymat.matdemo.denoiseDemo([n:noised signal(row vector)]) # see a denoising experiment\r\n\r\ndraw a matrix::\r\n\r\n >>> import mymat.matshow # draw a matrix on axes(require matplotlib)\r\n >>> ms = mymat.matshow.MatrixShow(A); ms.show()\r\n\r\n\r\nMethods and Functions\r\n---------------------\r\n\r\nother methods::\r\n\r\n __call__: A(ind) == A[ind]\r\n delete(ind1=row, ind2=col): delete row-rows and col-columns\r\n proj(ind1=row, ind2=col): =0 out of A[row, col], for example A.proj(ind1=COLON, ind2=[2,3])=[2,3] where A=[1,2,3,4]\r\n repmat((ind1, ind2)|ind): repeat matrix as in Matlab (like tile)\r\n just: cut matrix to a certain size, and supplement zeros if the size is too large.\r\n cat: as concatenate\r\n equal: (A == B == C).all()\r\n apply: A.apply(lambda x:x+1) == A+1\r\n plus: A.plus(n) == A + nI\r\n robinson: A.robinson(j, x) == A[j<-x], namely A[:,j]=x used in Cramer rule\r\n echelon: get the echelon form (include the corresponding column indexes)\r\n tril, triu, diag are similar to matlab\r\n row(col)_transform1/2/3: elementary row (column) transforms (Gauss tranforms)\r\n comat: get the co-matrix (similar with delete)\r\n cofactor: A.cofactor(i,j)=Aij get the cofactor based on comat\r\n rho: the spectral radius\r\n totex: to tex form of matrix\r\n tolineq: to tex form of linear equations wrt augment matrix\r\n argmin, argmax\r\n\r\n\r\nclass methods::\r\n\r\n MyMat.zeros, MyMat.ones, MyMat.random, MyMat.randint, MyMat.eye\r\n\r\n\r\nfunctions and variables::\r\n\r\n ind2ind: the most essential function\r\n times: translate single index to double index\r\n compind: get complementary index (called in proj)\r\n COLON: slice(None), COLON2=(COLON,COLON)\r\n\r\n\r\nmatrices::\r\n\r\n FM: Fourier matrix\r\n FIM: Fourier inverse matrix\r\n FUM: Fourier unitary matrix\r\n Ho: Horsehold matrix\r\n Ref: reflection matrix\r\n H: Hilbert matrix\r\n Elm1,Elm2,Elm3: elementary matrices (3 types)", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://git.oschina.net/williamzjc/mymat", "keywords": "numpy matrix matlab", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mymat", "package_url": "https://pypi.org/project/mymat/", "platform": "", "project_url": "https://pypi.org/project/mymat/", "project_urls": { "Homepage": "https://git.oschina.net/williamzjc/mymat" }, "release_url": "https://pypi.org/project/mymat/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "Subclass of numpy.matrix behaving as matrices in matlab.", "version": "1.1.0" }, "last_serial": 4449251, "releases": { "0.2.1": [], "1.0.1": [ { "comment_text": "", "digests": { "md5": "a5998010b8938ccb85c7ad1682d99e65", "sha256": "97ff14cc2282ba1b3e0a58f41fe000ac7e00c13a1c82e43e3731040cfc9344b6" }, "downloads": -1, "filename": "mymat-1.0.1.tar.gz", "has_sig": false, "md5_digest": "a5998010b8938ccb85c7ad1682d99e65", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17940, "upload_time": "2017-01-08T04:45:58", "url": "https://files.pythonhosted.org/packages/3b/9f/52e8f80538a3462513f819a204b9acc62d94f374df6dbda7a86e62323d16/mymat-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "5ce789d00173871625979522e1cc0a56", "sha256": "42b4d406b69fcd94ff62a83d4f3b5b9642e06f7979c9ab279e081a145d1e9727" }, "downloads": -1, "filename": "mymat-1.1.0.tar.gz", "has_sig": false, "md5_digest": "5ce789d00173871625979522e1cc0a56", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19877, "upload_time": "2017-05-24T04:53:27", "url": "https://files.pythonhosted.org/packages/04/74/ebd3de092218e510cab46fb60f6388748f9e611c7fb5c86d73e8b67e26f9/mymat-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5ce789d00173871625979522e1cc0a56", "sha256": "42b4d406b69fcd94ff62a83d4f3b5b9642e06f7979c9ab279e081a145d1e9727" }, "downloads": -1, "filename": "mymat-1.1.0.tar.gz", "has_sig": false, "md5_digest": "5ce789d00173871625979522e1cc0a56", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19877, "upload_time": "2017-05-24T04:53:27", "url": "https://files.pythonhosted.org/packages/04/74/ebd3de092218e510cab46fb60f6388748f9e611c7fb5c86d73e8b67e26f9/mymat-1.1.0.tar.gz" } ] }