# 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

## 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)…

## 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 &…

## 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 nummerically unstable behaviour so …

## 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