Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
1 answer
61 views

Scientific calculator using js

I am buildinng a scientific calculator using js. The normal calculator part is working but my scientific calculator is not working. Earlier I was using `eval( function for calculation but due to ...
Adarsh tripathi's user avatar
1 vote
1 answer
37 views

Compiled JAX functions slowing down for no reason

I am using Jax for scientific computing, specifically, calculating a pairwise interaction force across all the particles in my system in parallel. This is for a simulation of the dynamics of a ...
Yigithan Gediz's user avatar
0 votes
2 answers
73 views

Finding maximum of multiple arrays in respect to their index, that can vary

Problem description: I have got values that do correspond to specific conrer_ids, elements. From multiple sets of these values I need to find maximum ones and generate arrays containing conrer_ids, ...
Vybornak2's user avatar
1 vote
1 answer
417 views

Pivoted QR in Julia?

In Julia, the function qr(A) will perform a QR decomposition on a given matrix A. However, is there any function/way in Julia to do a "pivoted" QR decomposition on a given matrix?
James Rider's user avatar
0 votes
1 answer
181 views

How to initialize a container struct without knowing its size?

I am an amateur in C++, I am working on an scientific computing code. I defined a struct to store all the data input from the file. In the struct I have several 2D and 1D arrays whose dimensions ...
YS_Jin's user avatar
  • 55
2 votes
0 answers
100 views

Diagonal Matrix of Sigma Values in Julia

If I compute the SVD of a matrix A in Julia, it will give the sigma values of the matrix, BUT NOT in matrix form. However, if I want to assemble the sigma values of a matrix A into a diagonal matrix, ...
James Rider's user avatar
0 votes
1 answer
888 views

Efficient/parallel matrix routines on Apple silicon

I'm working in Physics, and as part of my job I have to do a lot of numerical calculations ("numerics"), 90+% of which involves the diagonalization of large matrices. At the moment, I use ...
dsfkgjn's user avatar
  • 13
0 votes
0 answers
36 views

UnboundLocalError: local variable 'rmeff' referenced before assignment

Hey I'm trying to compute the concentration of a tubular reactor with two reaction, I get this error thrown each time I run the code, I tried putting the variable in the function as global still ...
Votex5264421's user avatar
1 vote
1 answer
700 views

When to use xarray over numpy for medium rank multidimensional data?

I have some multidimensional data and was wondering if i should use xarray when speed is one, albeit not highest, of my concerns. I have a 4D array so it's not so big as to preclude me from using ...
Austin Benny's user avatar
3 votes
0 answers
341 views

How to calculate the path of a particle subject to a vortex?

I'm trying to draw a path of a particle starting at (x0,y0) subject to a vortex located at (xv,yv). This is inspired by Lorena Barba's AeroPython. As stated in the lesson, the motion should be ...
Ross Mariano's user avatar
0 votes
0 answers
138 views

Is there an effective way to fit the following two datasets with lsqcurvefit?

I have two complex datasets for which I intend to find a suitable function to fit them. The first dataset is presented as follows: As you can see, although complicated, it seems that this dataset is ...
tjk's user avatar
  • 3
0 votes
0 answers
76 views

pymc.Uniform giving ZeroProbability error: Stochastic alpha's value is outside its support, or it forbids its parents' current values

I am using a example given in web of pymc, when I try to run pymc.Uniform I am getting the following error --------------------------------------------------------------------------- ZeroProbability ...
Divyadeep harbola's user avatar
0 votes
1 answer
146 views

Finding the best linear section of data

I have some scientific data and wish to find the best region to fit a straight line in. Theoretically, the data should have a constant gradient but other influences effect the data such that there are ...
Stuart's Fanclub's user avatar
0 votes
1 answer
282 views

MATLAB: Does the execution of addpath/rmpath/savepath in one MATLAB instance affect other instances?

Does the execution of addpath/rmpath/savepath in one MATLAB instance affect other instances? Motivation: Imagine that you are developing a MATLAB package, which provides a group of functions to the ...
Nuno's user avatar
  • 266
0 votes
0 answers
272 views

Is MEX of MATLAB known to be slow on macOS?

Question: Is MEX of MATLAB known to be slow on macOS? Here, "slow" refers to the speed of setting MEX up, of compiling MEX code, and of running the MEX function. I have done some timing ...
Nuno's user avatar
  • 266
2 votes
1 answer
429 views

How do I add another coordinate label in Xarray?

I have an Xarray, say da = xr.DataArray([[1,2],[1,2]],coords={'x':['param1','param2'],'y':['idx','idx2']}) This is a 2D data array. As I build out my code, I would like to add another "column&...
Austin Benny's user avatar
1 vote
1 answer
307 views

SymPy `subs` Not Doing Anything

I have a differential equation for which I use sympy.solvers.ode.dsolve to solve, I get out ___________ ___________ -x⋅╲╱ E - V_max x⋅╲╱ E - V_max ψ(x) = C₁...
cgbsu's user avatar
  • 55
2 votes
2 answers
776 views

Collect similar terms in sympy

I'm solving the Maxwell Garnett equation with SymPy: solveset(Eq((e-m)/(e+2*m) = n*(a-m)/(a+2*m)), m) Is it possible to simplify the solution by grouping similar terms together like Mathematica does? ...
Antony Hatchkins's user avatar
1 vote
1 answer
3k views

Python equivalent for Matlab's fmincon for constrained nonlinear optimization

I'm currently trying to implement a Python script for solving a constrained nonlinear optimization problem with ~1000 variables and ~700 constraints (both linear and nonlinear). There already exists a ...
Bobbybobbobbo's user avatar
3 votes
1 answer
578 views

How to understand this number with "double scientific"-notation (~1e-9-4.999e-1) in matplotlib

I'm running a calculation that outputs a matplotlib plot with a vertical axis scaled with (see image below). ~1e-9-4.998e-1 This is very weird scaling and I'd like to make sure I understand the ...
FunkyPeanut's user avatar
  • 1,182
2 votes
1 answer
1k views

How to deal with large integers in NumPy?

I'm doing a data analysis project where I'm working with really large numbers. I originally did everything in pure python but I'm now trying to do it with numpy and pandas. However it seems like I've ...
lapurita's user avatar
  • 1,155
-1 votes
1 answer
812 views

Writing Python Script to Solve System of Four Equations in Python w/ Four Unknowns [closed]

I have a system of four equations with four unknowns posted below. Each equation (f1,f2,f3,f4) is set equal to zero, and I have tried using fsolve with no success. The issue may be that these are non-...
erkvos's user avatar
  • 19
1 vote
1 answer
308 views

Obtaining orthogonal left and right eigenvectors at similar computational speed in R/Python?

My goal is to find right and left eigenvectors of a diagonalizable, non-symmetric matrix m without inversion but so that they are still orthogonal to each other/ From ?eigen I would like to find the V^...
Hirek's user avatar
  • 473
1 vote
1 answer
488 views

Python: is there a faster alternative to using numpy's polyfromroots?

Using Python, I am looping over a large collection of sets of roots (represented as a 2-dimensional numpy array, essentially), and forming each time the monic polynomial having the set of roots (...
Malkoun's user avatar
  • 113
1 vote
1 answer
595 views

Numpy (or scipy) binning of time series values based on timestamps

I'm trying to bin (downsample) a time series based on its timestamps. For instance: import numpy as np import pandas as pd timestamps = np.linspace(0, 1000, 10000) values = np.random.random(10000) I ...
Alex Legaria's user avatar
0 votes
1 answer
128 views

How to compare amplitude from Android with iOS

So I've read various posts and blogs on how to get the amplitude from the microphone on Android. Multiple posts suggested using this implementation: minSize = AudioRecord.getMinBufferSize( ...
Skrettinga's user avatar
0 votes
1 answer
487 views

Fast fourier transformation in python using scipy

I am using scipy.fft module for calculating Fourier transformation of an array. Now using the module I got the transformation. But my question is how do I know the elements in the transformed array ...
Manish kumar gupta's user avatar
1 vote
1 answer
480 views

cvxpy + mosek: The lower bound specified is not a number (nan)

In below code snippet I am trying to do a very simple linear regression using cvxpy and mosek solver weight = df2['weight'].to_numpy() A = df2[ regressors ].to_numpy() x = cp.Variable(len(regressors ))...
Taylor Fang's user avatar
2 votes
0 answers
364 views

How to implement shooting method with coupled ODEs

I want to simulate the laser power along a silica fiber. The ODEs and the used parameters can be found in the paper linked below. Note that I converted all units to SI units in my code. The authors of ...
Alex's user avatar
  • 21
2 votes
0 answers
70 views

Equivalent of `log1p` for matrices, aka `logdet_eyep`

Most scientific libraries (e.g. numpy/scipy) provide a numerically stable implementation of log1p(x) = log(1 + x) which yields sensible values, even when x is so small in magnitude that floating point ...
Till Hoffmann's user avatar
1 vote
0 answers
51 views

Ignore failed factorisations in numpy/scipy cholesky factorisations

I'm trying to compute the Cholesky decomposition of a large number of hermitian matrices, import numpy as np from numpy import linalg H = np.random.rand(1000000,10,10) H = 0.5*(H + H.transpose(0,2,1)) ...
catalogue_number's user avatar
0 votes
1 answer
598 views

Does sympy have an in built method to set multiple polynomials equal to each other?

Here’s a simple example of how i begin to attempt to solve a system of 2 equations in sympy. My goal is to first set equal to each other my equations: import sympy as sp x,y,z = sp.symbols("X, Y, ...
pysolver33's user avatar
0 votes
1 answer
213 views

Filtering a noisy 1D time-series

I have a noisy, 1-Dimensional time-series, which I'd like to filter so as to obtain the contained "signal". The time-series in question is a collection of timestamps, each of which ...
10GeV's user avatar
  • 465
1 vote
1 answer
202 views

Need an efficient way to plot planes from large sets of 3D coordinates

I have some detector data collected on a 2D camera, I then convert it to a lab frame so I end up with an (x^2+y^2) and z coordinate for each pixel in the image. But then the object rotates about it's ...
Gary's user avatar
  • 13
2 votes
1 answer
1k views

Optimize performance on a SLURM cluster

I am writing you after many attempts I have done on a CPU cluster so structured: 144 standard compute nodes 2× AMD EPYC 7742, 2× 64 cores, 2.25 GHz 256 (16× 16) GB DDR4, 3200 MHz InfiniBand HDR100 (...
Vito Genna's user avatar
1 vote
0 answers
278 views

How do I solve this differential equation using sympy or py-pde?

I would like to solve the following inhomogeneous partial differential equation: I have been reading the documentation for py-pde and figure I should make a 'ScalarField' object representing the RHS, ...
Joe Natal's user avatar
2 votes
0 answers
118 views

MatrixFree Linear Operators vs. Sparse Arrays

How to quantify the performance of matrix-free operators and sparse arrays for matrix-vector products. Specifically, what is speed cost of having matrix-vector products dominated by function calls ...
Mohamed AbdElrahman's user avatar
0 votes
2 answers
629 views

Using Sympy: TypeError: '>=' not supported between instances of 'NoneType' and 'int'

So, I have this code below: from sympy import Symbol, solve, nsolve x1 = Symbol('x1') x2 = Symbol('x2') w1 = Symbol('w1') w2 = Symbol('w2') eq1 = w1 + w2 eq2 = (w1 * x1) + (w2 * x2) eq3 = (w1 * x1**...
Sabrina Reyes's user avatar
4 votes
1 answer
278 views

How to speed up this for loop containing kronecker product?

I want to speed up the following for loop. % Use random matrices for testing. % Elapsed time of the following code is around 19 seconds. % So, when N is large, it's very slow. n= 800; N =100; k =10;...
learner's user avatar
  • 151
3 votes
2 answers
56 views

Obtaining columns of a matrix satisfying multiple booleans in Julia

I am trying to obtain only those columns of a matrix that satisfy two or more boolean conditions. More specifically, I am trying to find only those eigenvectors of a matrix based on certain ...
quics-ilver's user avatar
0 votes
1 answer
784 views

Scatter plot for points in an array above a given value

import matplotlib.pyplot as plt import numpy as np fig = plt.figure() eps = 0.8 X = np.linspace(-1, 1, 100) Y = np.linspace(-1, 1, 100) X, Y = np.meshgrid(X, Y) Z = np.exp(-X**2-Y**2) data_zero_x =...
JoeGlas's user avatar
  • 85
1 vote
3 answers
198 views

How to split a user inputted list of 8 numbers into quarters

Currently, I have data = input('Please input 8 numbers \n') What I want to do is split this list into quarters so I may input them into matrices A and B of a 2x2 format
Drev1n's user avatar
  • 11
0 votes
1 answer
31 views

Trim for loop between datapoints from a 2d array

I loaded a file.dat as a 2d array data = np.loadtxt('file.dat') I have used a for loop as to iterative over all points in this array for i in range(len(data): If I wanted to only do a for loop ...
Kryoomi's user avatar
  • 13
0 votes
0 answers
157 views

Numpy/Python Scalability

I use Python and Numpy mainly for scientific programming. A typical task is to construct and then diagonalize many medium-sized matrices. I try to avoid any for loops and mainly use advanced numpy ...
Pickniclas's user avatar
1 vote
0 answers
261 views

Eclipse IDE for Scientific Computing for C++ on windows

I have installed the latest version of Eclipse IDE for scientific computing 2020-12. I am trying to run an MPI c++ project but I get this error : Program "mpic++" not found in PATH I have ...
MA19's user avatar
  • 580
0 votes
1 answer
562 views

Why VisualBasic (VB.NET) faster than C++ code in this example?

I have been benchmarking an iterative calculation, a Lapalace equation solver for electrostatics, that uses the Jacobi method. I wrote the same algorithm in Visual Basic and C++ (and other languages ...
Luis's user avatar
  • 36
2 votes
1 answer
96 views

Collapse Numpy arrays to scalar when, e.g., multiplying by zero

I'm a bit surprised that I couldn't find an easy when to collapse dimensions of a Numpy array containing identical values. Let me explain. I might have to multiply to time series implemented as arrays,...
Jean-Baptiste's user avatar
0 votes
1 answer
61 views

Is there a good framework or package in python to compare something over a number of parameters?

When working in python for research I often end up with some problem where I want to compare a result over a different number of parameters. params1 = [0.1, 0.2, 0.3] params2 = [5, 10, 50] parmas3 = ...
Christian's user avatar
  • 1,411
1 vote
0 answers
221 views

`map_blocks` leads to tuple indices error in Dask

I am trying to apply a simple operation in parallel on a datacube, but I keep running into a TypeError. This is my input datacube (called dcube): <xarray.DataArray 'A' (time: 6, pol: 1, y: 823, x: ...
shaunakde's user avatar
  • 3,098
0 votes
1 answer
712 views

Create uniformly spaced points in a given direction

Suppose I have a line in 2D and in an arbitrary direction. I would like to create uniformly spaced points along this line. I thought of one way to code this but seems like it can get messy, are there ...
C-Math's user avatar
  • 63

1
2 3 4 5
14