Re: [Numpy-discussion] Software Capabilities of NumPy in Our Tensor Survey Paper

2016-01-15 Thread Yuxiang Wang
I echo with Robert that the contraction can be done with np.einsum(). Also, check out the np.tensordot() as well - it can also be used to perform contraction. Shawn On Fri, Jan 15, 2016 at 12:32 PM, Robert Kern wrote: > On Fri, Jan 15, 2016 at 5:30 PM, Nathaniel Smith

Re: [Numpy-discussion] Should I use pip install numpy in linux?

2016-01-08 Thread Yuxiang Wang
Dear Nathaniel, Gotcha. That's very helpful. Thank you so much! Shawn On Thu, Jan 7, 2016 at 10:01 PM, Nathaniel Smith <n...@pobox.com> wrote: > On Thu, Jan 7, 2016 at 6:18 PM, Yuxiang Wang <yw...@virginia.edu> wrote: >> Dear all, >> >> I know that in Windows,

[Numpy-discussion] Should I use pip install numpy in linux?

2016-01-07 Thread Yuxiang Wang
Dear all, I know that in Windows, we should use either Christoph's package or Anaconda for MKL-optimized numpy. In Linux, the fortran compiler issue is solved, so should I directly used pip install numpy to get numpy with a reasonable BLAS library? Thanks! Shawn -- Yuxiang "Shawn" Wang

Re: [Numpy-discussion] future of f2py and Fortran90+

2015-12-03 Thread Yuxiang Wang
Too add to Sturla - I think this is what he mentioned but in more details: http://www.fortran90.org/src/best-practices.html#interfacing-with-python Shawn On Tue, Jul 14, 2015 at 9:45 PM, Sturla Molden wrote: > Eric Firing wrote: > >> I'm curious:

Re: [Numpy-discussion] IDE's for numpy development?

2015-04-08 Thread Yuxiang Wang
I think spyder supports code highlighting in C and that's all... There's no way to compile in Spyder, is there? Shawn On Tue, Apr 7, 2015 at 2:46 AM, Suzen, Mehmet msu...@gmail.com wrote: Spyder supports C. Thanks for correcting this. I wasn't aware of it. How was your experience with it?

Re: [Numpy-discussion] IDE's for numpy development?

2015-04-01 Thread Yuxiang Wang
That would really be hilarious - and IFortran probably! :) Shawn On Wed, Apr 1, 2015 at 12:07 PM, Benjamin Root ben.r...@ou.edu wrote: mixed C and python development? I would just wait for the Jupyter folks to create IC and maybe even IC++! On Wed, Apr 1, 2015 at 12:04 PM, Charles R Harris

[Numpy-discussion] F2PY cannot see module-scope variables

2015-01-26 Thread Yuxiang Wang
Dear all, Sorry about being new to both Fortran 90 and f2py. I have a module in fortran, written as follows, with a module-scope variable dp: ! testf2py.f90 module testf2py implicit none private public dp, i1 integer, parameter ::

Re: [Numpy-discussion] F2PY cannot see module-scope variables

2015-01-26 Thread Yuxiang Wang
/02/f2py-on-64bit-windows-python27.html On Mon, Jan 26, 2015 at 10:29 PM, Yuxiang Wang yw...@virginia.edu wrote: Dear all, Sorry about being new to both Fortran 90 and f2py. I have a module in fortran, written as follows, with a module-scope variable dp

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-03 Thread Yuxiang Wang
with the legacy code with no problem. I'll definitely give it a try! Thanks again for all the help Sturla, Shawn On Fri, Jan 2, 2015 at 8:22 AM, Sturla Molden sturla.mol...@gmail.com wrote: Yuxiang Wang yw...@virginia.edu wrote: 4) I wanted to say that it seems to me, as the project gradually

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Yuxiang Wang
.], [ 0., 0., 0.], [ 0., 0., 0.]]) Was I doing something wrong here? Shawn On Thu, Jan 1, 2015 at 1:56 PM, Nathaniel Smith n...@pobox.com wrote: On Thu, Jan 1, 2015 at 6:00 PM, Yuxiang Wang yw...@virginia.edu wrote: Dear all, I am currently using a piece of C code, where one

[Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Yuxiang Wang
Dear all, I am currently using a piece of C code, where one of the input argument of a function is **double. So, in numpy, I tried np.ctypeslib.ndpointer(ctypes.c_double), but obviously this wouldn't work because this is only *double, not **double. Then I tried

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Yuxiang Wang
1) @Strula Sorry about my stupid mistake! That piece of code totally gave away how green I am in coding C :) And yes, that piece of code works like a charm now! I am able to run my model. Thanks a million! 2) @Strula and also thanks for your insight on the limitation of the method. Currently I

[Numpy-discussion] Why is numpy.ma.extras.clump_masked() not in main documentation?

2014-12-28 Thread Yuxiang Wang
Dear all, I am really glad to find out a very useful function called numpy.ma.extras.clump_masked(), and it is indeed well documented if you look into the source. However, may I ask why does it not show up in the main documentation website

Re: [Numpy-discussion] Why is numpy.ma.extras.clump_masked() not in main documentation?

2014-12-28 Thread Yuxiang Wang
...@gmail.com wrote: On Sun, Dec 28, 2014 at 8:48 PM, Yuxiang Wang yw...@virginia.edu wrote: Dear all, I am really glad to find out a very useful function called numpy.ma.extras.clump_masked(), and it is indeed well documented if you look into the source. However, may I ask why does it not show up

[Numpy-discussion] Implementation of tensor product and tensor contraction?

2014-11-25 Thread Yuxiang Wang
Dear all, I have been doing tensor algebra recently (for continuum mechanics) and was looking into two common operations: tensor product tensor contraction. 1. Tensor product One common usage is: a[i1, i2, i3, ..., iN, j1, j2, j3, ..., jM] = b[i1, i2, i3, ..., iN] * c[j1, j2, j3, ..., jM] I

Re: [Numpy-discussion] Implementation of tensor product and tensor contraction?

2014-11-25 Thread Yuxiang Wang
calculated. -Shawn On Tue, Nov 25, 2014 at 11:12 PM, Charles R Harris charlesr.har...@gmail.com wrote: Take a look as einsum, it is quite good for such things. Chuck On Tue, Nov 25, 2014 at 9:06 PM, Yuxiang Wang yw...@virginia.edu wrote: Dear all, I have been doing tensor algebra recently

Re: [Numpy-discussion] Why ndarray provides four ways to flatten?

2014-10-27 Thread Yuxiang Wang
Hi Alexander, In my opinion - because they don't do the same thing, especially when you think in terms in lower-level. ndarray.flat returns an iterator; ndarray.flatten() returns a copy; ndarray.ravel() only makes copies when necessary; ndarray.reshape() is more general purpose, even though you

[Numpy-discussion] Inverse function of numpy.polyval()

2014-05-19 Thread Yuxiang Wang
Dear all, I was wondering is there a convenient inverse function of np.polyval(), where I give the y value and it solves for x? I know one way I could do this is: import numpy as np # Set up the question p = np.array([1, 1, -10]) y = 100 # Solve p_temp = p p_temp[-1] -= y x = np.roots(p_temp)

Re: [Numpy-discussion] Second order gradient in numpy

2014-05-02 Thread Yuxiang Wang
Hi Chris, Thank you! This is useful information. Unfortunately, I am doing this on data from a sensor and would be hard to fit to a simple polynomial while avoiding overfitting. Thanks again! Shawn On Thu, May 1, 2014 at 7:01 PM, Chris Barker chris.bar...@noaa.gov wrote: On Thu, May 1, 2014

Re: [Numpy-discussion] Second order gradient in numpy

2014-05-02 Thread Yuxiang Wang
:42 PM, Christian K. ckk...@hoc.net wrote: Am 01.05.14 18:45, schrieb Yuxiang Wang: Hi all, I am trying to calculate the 2nd-order gradient numerically of an array in numpy. import numpy as np a = np.sin(np.arange(0, 10, .01)) da = np.gradient(a) dda = np.gradient(da

[Numpy-discussion] Second order gradient in numpy

2014-05-01 Thread Yuxiang Wang
Hi all, I am trying to calculate the 2nd-order gradient numerically of an array in numpy. import numpy as np a = np.sin(np.arange(0, 10, .01)) da = np.gradient(a) dda = np.gradient(da) This is what I come up. Is the the way it should be done? I am asking this, because in numpy

Re: [Numpy-discussion] shortcut nonzero?

2014-02-25 Thread Yuxiang Wang
Hi Alan, If you are only dealing with 1d array, What about: np.nonzero(your_array)[0][:k] ? -Shawn On Tue, Feb 25, 2014 at 2:20 PM, Alan G Isaac alan.is...@gmail.com wrote: Is there a shortcut version for finding the first (k) instance(s) of nonzero entries? I'm thinking of Matlab's