4,441 questions
2
votes
1
answer
124
views
PCA with arpack returns different values when the order of observations change, but why?
I have recently noticed that when I change the order of the observations in a sparse array, scikit-learn PCA with svd_solver="arpack" returns different floating point numbers. Is this an ...
1
vote
2
answers
87
views
Confused about how tf.keras.Sequential works in TensorFlow – especially activation and input_shape
I'm learning TensorFlow to build machine learning models in Python. I tried following the official documentation on creating a simple classification model, but I couldn't clearly understand the tf....
0
votes
0
answers
52
views
MICCG(0) for a fluid simulation fails at Neumann boundaries
I am trying to follow Robert Bridson's Fluid Simulation Notes (https://www.cs.ubc.ca/~rbridson/fluidsimulation/fluids_notes.pdf) to implement my own eulerian fluid simulator for the first time.
I was ...
0
votes
1
answer
126
views
It is possible to compute both the size and values for a std array in a constexpr function?
I am trying to express the structure of a sparse matrix (and the structure resulting from sparse matrix operations) at compile time with template parameters and constexpr functions.
I've defined this ...
2
votes
0
answers
185
views
How to reuse cuDSS factors when solving a system of linear equations Ax=b
I am using cuDSS to solve a set of Ax=b equations as follows
cudssMatrixType_t mtype = CUDSS_MTYPE_SPD;
cudssMatrixViewType_t mview = CUDSS_MVIEW_UPPER;
cudssIndexBase_t base = CUDSS_BASE_ZERO;
...
2
votes
1
answer
111
views
How to convert Eigen Sparse Matrix to Cuda CuSparse Matrix
I am trying to convert an Eigen Sparse Matrix of size NxN to CuSparse matrix so that I can use CUDA to solver the matrix Ax=B. Came across this thread which is pretty old (Convert Eigen::SparseMatrix ...
1
vote
1
answer
54
views
How to produce tensor of first occurrencies of another tensor using PyTorch
Let's say we have an ordered 1D tensor of ints/longs t.
I want to produce a new tensor a with size max(t) where each term a[i] contains the first occurrence of the value i in the tensor t.
We could ...
0
votes
1
answer
67
views
Matrix free arnoldi
I want to do a "matrix-free eigenvalue evaluation" of a unitary matrix using ARPACK package. Unitary matrix comes from a sparse hermitian matrix, something that happens in many-body problem.
...
0
votes
1
answer
39
views
Is it possible to subdivide the surface of a 3D Sphere (Earth) using 256 sided polygons?
Background for purpose sparse/compressible data structure/compressible honeycumbs, vague description to give you an idea: This would allow an array of [0..255] connection points hopefully. If all of ...
3
votes
2
answers
105
views
Fastest way to find first ZERO element of a sparse matrix
When using sparse matrices, it's easy to find non-zero entries quickly (as these are the only elements stored). However, what's the best way to find the first ZERO entry? Using approaches like find(X==...
1
vote
0
answers
134
views
Optimizing the running time of solving an SDP in CVXPY
I am trying to optimize the following part of my code that involves solving a semi-definite programming (SDP) in CVXPY.
# optimization variables X and V
V = cp.Variable((p,p))
X = cp.Variable((num,p))...
1
vote
0
answers
34
views
Calculating CrossEntropyLoss over sparse tensors
While the following works as expected:
import torch
from torch.nn import CrossEntropyLoss
loss = CrossEntropyLoss()
T1 = torch.randn(10, 20, 4, 4) # The BatchSize is a 10 times repeated tensor (1,20,...
2
votes
1
answer
142
views
Generalized Nonsymmetric Eigensolver Python
How do I solve a nonsymmetric eigenproblem. In terms of scipy.sparse.linalg.eigsh the matrix needs to be "real symmetric square matrix or complex Hermitian matrix A" (https://docs.scipy.org/...
1
vote
1
answer
51
views
superlu causing problems with mlpack in Rcpp
I have the following Rcpp code
#include <RcppArmadillo.h>
#define _USE_MATH_DEFINES
#include<cmath>
#include <boost/math/special_functions/bessel.hpp>
#include <mlpack.h>
#...
1
vote
0
answers
48
views
Can't generate a simple CuSparseMatrixCOO using CUDA from Julia
At the moment I'm trying to build a COO using the CUSPARSE library. Looking at the documentation, and the function arguments, the way to create this is using the row and column indices followed by the ...
0
votes
1
answer
58
views
Sparse matrix in pandas/scipy with row and column indices
I have a dataframe in pandas that looks like this:
>>> df[['BranchNumber', 'ModelArticleNumber', 'ActualSellingPrice']].info()
<class 'pandas.core.frame.DataFrame'>
Index: 447970 ...
0
votes
0
answers
44
views
SPMV functions in MKL Library cannot work properly on my computer. How can I fix it?
This is my first time working with the MKL library. After referring to the official documentation, I obtained the latest version of the MKL library via the apt package manager in the WSL2 Ubuntu ...
0
votes
1
answer
200
views
SciPy sparse matrix csr_matrix and csc_matrix functions - how much intermediate memory do they use?
For the scipy functions csr_matrix, and csc_matrix, and specifically the forms that take the row and column indices:
csr_matrix((data, (row_ind, col_ind)), [shape=(M, N)])
csc_matrix((data, (row_ind, ...
1
vote
1
answer
59
views
scipy coo_matrix consider some small numbers as 0.0 but still put in sparse matrix
I use some python and numpy/scipy code and produce a sparse array:
<COOrdinate sparse array of dtype 'float64'
with 21 stored elements and shape (403, 196)>
Coords Values
(206, 138) ...
0
votes
0
answers
140
views
Efficiently compute the diagonal of the inverse of a sparse matrix
In Python have a large NxN sparse matrix representing the precision matrix Q (inverse covariance matrix) of a multivariate Gaussian distribution. I am interested in obtaining the marginal variances of ...
3
votes
0
answers
282
views
Solving sparse linear system on GPU is much slower than CPU
Below is the code which solves a sparse linear system:
import cupyx
import cupyx.scipy.sparse.linalg
import time
import scipy
import scipy.sparse.linalg
import pathlib
file_dir = str(pathlib.Path(...
1
vote
1
answer
76
views
python and sparse matrix made out of 2X2 matrices
I can straight forwardly create the matrix C as (where the elements 0, A, B are 2X2 matrices)
[ 0 A 0 0 0 0 ... 0 0
B 0 A 0 0 0 ... 0 0
0 B 0 A 0 0 ... 0 0
0 0 B 0 A 0 .... ...
0
votes
2
answers
174
views
Efficient Hadamard product of matrix-matrix multiplication
I am trying to compute in Python the following operation: (AB).C, where A,B,C are sparse matrices, and with the lower dot " ." I indicated the Hadamard (entry-wise) product of matrices, ...
0
votes
0
answers
34
views
Problematic destructor in a circularly linked sparse matrix program [duplicate]
This is not a homework problem but for self-study.
I am writing a program that reads in user input and transforms it into a sparse matrix (operator>>), adds two sparse matrices (operator+), and ...
0
votes
1
answer
115
views
Plot a path in a very large 2D matrix using Matplotlib
I want to plot a path in a very large (e.g. 500K x 500K) 2D matrix. My current approach is creating an uint8 np array (for space-saving reasons, as I only have 4 possible values) and plotting it with ...