I am building a cholesky factorisation algorthim as proposed from the book: Linear Algebra and Optimisation for Machine Learning They provide the following algorthim: I have attempted this with python with the following algorithm: When testing this on a matrix I get upper triangular as opposed to lower triangular. Where was I mistaken? Answer You don’t even need to look
Tag: linear-algebra
np.linalg.multi_dot for R
I’m trying to do a nested dot result is effectively x.dot(M.dot(M)): In python this loop can be reduced by: Is there something similar for R? Answer As @akrun commented, you could also use Reduce:
Solve linear system in python with different set of roots
I’m having a problem where I have this linear system for example I need to solve for x1, x2, and x3 but every library I used gave me only x1=x2=x3=0 as a solution it’s correct but the system accepts other solution. I am looking for a solution to avoid zeros as answer. Thanks for helping. Answer That’s more of a
Solving linear equation of complex matrices
I have a linear equation of a form ax=b where b is a complex matrix, and a is a real matrix. I’m expecting solution x to be a complex vector. When trying the numpy.linalg.solve(a,b) function, I’m getting this warning: ComplexWarning: Casting complex values to real discards the imaginary part How do I solve this equation to preserve the complex numbers?
Values in Python lists getting overwritten
I am calculating some values for a certain type of matrix A of varying sizes. Namely the backward error, forward error, condition number, and the error magnification (everything with the infinity norm). My values get calculated and then I am trying to put them into lists, looping through increasing sizes of the matrix A. The problem is that after every
Compute sum of power of large sparse matrix
Given a query vector (one-hot-vector) q with size of 50000×1 and a large sparse matrix A with size of 50000 x 50000 and nnz of A is 0.3 billion, I want to compute r=(A + A^2 + … + A^S)q (usually 4 <= S <=6). I can above equation iteratively using loop but I want to more fast method. First
Vectorize else-if statement function using numpy
I have an array of 3 dimensional vectors vec and I want to find a perpendicular vector res_vec to each of those vectors respectively. Using other methods I got some numerically unstable behaviour so I just check for the smallest component of that vector and set it to zero, while exchanging the two components that are left and negating one
How does pytorch broadcasting work?
produces a Tensor with size: torch.Size([4,4]). Can someone provide a logic behind this? Answer PyTorch broadcasting is based on numpy broadcasting semantics which can be understood by reading numpy broadcasting rules or PyTorch broadcasting guide. Expounding the concept with an example would be intuitive to understand it better. So, please see the example below: Now for torch.add(t_rand, t_ones), visualize it