The cheat sheet vk4/16/2023 The normal matrix multiplication when a dense matrix is multiplied with a dense matrix or a sparse matrix is multiplied with a sparse matrix or a dense matrix īullshit when a dense matrix is multiplied with a sparse matrix. The element-wise matrix multiplication when dense arrays are used. The normal matrix multiplication when sparse and/or dense matrices are used. The behavior and result of both options differ depending on the type of the used matrices (resp. There are two options on multiplying two matrices: the * operator and the dot() function. The addition of a constant adds the constant to every element of a matrix (only available for dense matrices). TODO: crazy element access magic, single elements, entire rows, sub-matrices k = 0 is the main diagonal, k 0 is above. Referenceĭiagonal above which to zero entries. Reference (arg, k=0, format="csr") # Zero entries in the lower triangle of an array. Sparse (arg, k=0, format="csr") # Zero entries in the upper triangle of an array. (1) Construct an empty array, without initializing the entries (an array with random entries): There are some utility functions to create special matrices/arrays: > _matrix((values, (rows, columns)), shape=, dtype=int) ] # (transformed to a dense matrix for visualization). The type of the entries in the matrix ('integer', 'float', 'string', etc.). * a tuple (data, (rows, cols), to construct a matrix A where A, cols] = data or * a tuple (m, n), to construct an empty matrix with shape (n, m) or The data to create the CSR matrix from, given as Sparse _matrix(arg, shape=None, dtype=None) Reference _matrix(arg, shape=None, dtype=None) Reference Matrices are strictly 2-dimensional, while arrays are n-dimensional (the term array is a bit misleading here). In NumPy, there are two concepts of dense matrices: matrices and arrays. Dense matrices are more feature-rich, but may consume more memory space than sparse matrices (in particular if most of the entries in a matrix are zero). We distinguish between dense matrices and sparse matrices (Note: The color code will be used consistently throughout this cheat sheet).ĭense matrices store every entry in the matrix, while sparse matrices only store the non-zero entries (together with their row and column index). The routine to install NumPy and SciPy depends on your operating system.Īpt-get install python3-numpy python3-scipyįor all other systems (Windows, Mac, etc.) see the instructions given on the offical SciPy website. A library that allows to work with arrays and matrices in Python.Īnother library built upon NumPy that provides advanced Linear Algebra stuff.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |