Skip to content
Advertisement

Tag: linear-algebra

Cholesky factorisation not lower triangular

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

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:

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

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

Advertisement