Re: [ojAlgo-user] Interface analogous to Numpy?
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Bruno D. <ab...@ma...> - 2012-04-20 12:50:54
|
Dear Anders Peterson, > I looked at the ndarray "interface". Some things look a bit scary... Are all > the attributes and methods mentioned on that page public and non-optional? Regarding the methods, many of them can be implemented as stride-and-offset shuffling and calculation, for example * ndarray.repeat * ndarray.diagonal * ndarray.reshape * ndarray.flatten * ndarray.swapaxes * ndarray.ravel * ndarray.view Many others (min, argmin, round, sum, mean, var, prod, all, any ...) are easy to add. I hope they cover most of the applications. We'll see. Best regards Bruno Daniel Bruno Daniel wrote: > Dear Anders Peterson, > >> I looked at the ndarray "interface". Some things look a bit scary... Are all >> the attributes and methods mentioned on that page public and non-optional? > > Ok, let's see: > > http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html > There are many fields which are all public. We could replace them by set- and > get methods in the adapter. Most of them are used often. In consider only > real, imag, __array_priority__ as optional: > > "ndarray.flags Information about the memory layout of the array. > ndarray.shape Tuple of array dimensions. > ndarray.strides Tuple of bytes to step in each dimension when traversing an array. > ndarray.ndim Number of array dimensions. > ndarray.data Python buffer object pointing to the start of the array's data. > ndarray.size Number of elements in the array. > ndarray.itemsize Length of one array element in bytes. > ndarray.nbytes Total bytes consumed by the elements of the array. > ndarray.base Base object if memory is from some other object. > ndarray.dtype Data-type of the array's elements. > > ndarray.T Same as self.transpose(), except that self is returned if self.ndim < 2. > ndarray.real The real part of the array. > ndarray.imag The imaginary part of the array. > ndarray.flat A 1-D iterator over the array. > __array_priority__" > > ndarray.strides and ndarray.shape are the most important for creating > views. We would need an additional offset, because there are no pointers to > array parts in Java. > > For instance a vector-view of the third column of an m x n non-view, > row-order matrix A would roughly look like this: > > shape = tuple(m, 1) > offset = 2 * m > base = the same array as in A, no copy > strides = tuple(n) > size = m > ndim = 1 > > The transpose of the same matrix would roughly look like this: > > shape = tuple(m, n) > offset = 0 > base = the same array as in A, no copy > strides = the reverse of A.strides = tuple(1, n) > size = the same as in A > ndim = the same as in A = 2 > > If A is already a view there will be other values in offset and strides. > > These are for interfacing C programs. I hope they are not used too often in > common Numpy programs. Stefan Richthofer, what do you think? > > "The Array Interface. > __array_interface__ Python-side of the array interface > __array_struct__ C-side of the array interface" > ndarray.ctypes An object to simplify the interaction of the array > with the ctypes module." > >> Currently ojAlgo supports double, BigDecimal, ComplexNumber and >> RationalNumber elements with the ArrayAnyD class. Are other types required? > > Integers are quite common. The other types (there are many of them) could be > added later: > http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#arrays-dtypes > >> How about I create a sandbox version control system (for experimental code) over at http://code.google.com/p/ojalgo/ >> >> What do you prefer: Subversion, Git or Mercurial? > Thanks, Git would be nice, Subversion is also ok. > > Best regards > Bruno Daniel > > Anders Peterson wrote: >> Getting some small application that (only) depends on NumPy to run on Jython would be a proof of concept. >> >> I looked at the ndarray "interface". Some things look a bit scary... Are all the attributes and methods mentioned on that page public and non-optional? >> >> Currently ojAlgo supports double, BigDecimal, ComplexNumber and RationalNumber elements with the ArrayAnyD class. Are other types required? >> >> How about I create a sandbox version control system (for experimental code) over at http://code.google.com/p/ojalgo/ >> >> What do you prefer: Subversion, Git or Mercurial? >> >> /Anders >> >> >> On 19 apr 2012, at 22:21, B.D. wrote: >> >>> Dear Mr. Peterson, >>> >>>> Don't talk too much - just do it. Start with the most simple case. >>> >>> yes, you're right. I think this is a nice collection of simple unit tests for >>> me: http://www.scipy.org/Numpy_Example_List >>> >>> See you later, >>> B.D. >>> >>> >>> Anders Peterson wrote: >>>> Let's call it Jumpy... >>>> >>>> Since I'm not a python/jython/numpy/scipy user I think someone else should take the lead here. >>>> >>>> Don't talk too much - just do it. Start with the most simple case. >>>> >>>> I'm definitely interested in ways to make ojAlgo more useful. >>>> >>>> /Anders >>>> >>>> >>>> On 19 apr 2012, at 15:39, Stefan Richthofer wrote: >>>> >>>>> Hello together, >>>>> I also often thought about the idea to have a numpy-substitute for java, but always feared the enormous effort related to it. >>>>> >>>>> Be aware of the high Potential of the idea. >>>>> >>>>> Having a numpy substitute in java would enable a huge amount of scientific python-code to run directly in java via jython (maybe with a slight modification of the imports). >>>>> >>>>> Jython's main issue keeping it from being very useful is, that it does not support external (native) libraries written for Python. >>>>> >>>>> I regard numpy as one of the most important of these and I believe, that a significant amount of scientific python-code has numpy as the only non-python-core-dependency and thus could run via jython, if there was a numpy for java. >>>>> >>>>> Maybe you could consider a cooperation with the jython-developers at http://www.jython.org ...? >>>>> It should be highly in their interest to have a numpy implementation for java. >>>>> >>>>> >>>>> Greetings >>>>> >>>>> Stefan >>>>> >>>>> >>>>> >>>>> -------- Original-Nachricht -------- >>>>>> Datum: Thu, 19 Apr 2012 13:56:49 +0200 >>>>>> Von: Anders Peterson <an...@op...> >>>>>> An: oja...@li... >>>>>> Betreff: Re: [ojAlgo-user] Interface analogous to Numpy? >>>>> >>>>>> Short anser is yes, but you have to be more specific regarding what you >>>>>> want/need and willing to do some of the work yourself. >>>>>> >>>>>> ojAlgo has multi/any-dimensional arrays: >>>>>> >>>>>> http://ojalgo.org/generated/org/ojalgo/array/ArrayAnyD.html >>>>>> >>>>>> Frankly I don't really know what to do with them. I tend to only use 1- or >>>>>> 2-dimensional data structures. I created them because they were a >>>>>> generalization of what I needed that *could* become useful. >>>>>> >>>>>> I guess the various MatrixStore implementations and the >>>>>> MatrixStore.Builder does much of what you want, but only for 2-dim arrays (and with wrong >>>>>> syntax). >>>>>> >>>>>> http://ojalgo.org/generated/org/ojalgo/matrix/store/MatrixStore.html >>>>>> http://ojalgo.org/generated/org/ojalgo/matrix/store/MatrixStore.Builder.html >>>>>> >>>>>> In ojAlgo the description of the array shape/structure is fixed as defined >>>>>> in AccessUtils >>>>>> >>>>>> http://ojalgo.org/generated/org/ojalgo/access/AccessUtils.html >>>>>> >>>>>> Would that need to be changed? (I hope not.) >>>>>> >>>>>> /Anders >>>>>> >>>>>> >>>>>> On 19 apr 2012, at 11:35, B.D. wrote: >>>>>> >>>>>>> Dear developers, >>>>>>> >>>>>>> I'm primarily interested in Machine Learning and Data analysis. Thanks >>>>>> for the >>>>>>> good work, I appreciate the ojAlgo library very much! However, most new >>>>>>> algorithms and applications in this field are still written in Python >>>>>> for >>>>>>> Numpy/Scipy, not Java. I just had an idea: >>>>>>> >>>>>>> If one could offer classes/interfaces in pure Java with similar >>>>>> functionality >>>>>>> and names as in >>>>>>> >>>>>>> http://docs.scipy.org/doc/numpy/reference/ , >>>>>>> >>>>>>> in particular ndarray >>>>>>> >>>>>>> http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html >>>>>>> >>>>>>> (e.g. strides in matrices and vectors, transposition, reshaping of >>>>>> matrices as >>>>>>> a view without copying, many views on the same matrix data), then one >>>>>> could >>>>>>> rather easily translate Python programs using Numpy to pure Java without >>>>>>> reinventing the wheel and offer the excellent Python software for Java >>>>>> under >>>>>>> the same license as the original. >>>>>>> >>>>>>> There are syntax limitations in Java, so >>>>>>> >>>>>>> A[2:5, :] >>>>>>> >>>>>>> would have to be translated to some intutive name or even a crazy >>>>>> mnemonic like >>>>>>> >>>>>>> A.viewI_c_icI(2, 5) >>>>>>> >>>>>>> (I = [ or ], >>>>>>> i = comma, >>>>>>> c = colon, >>>>>>> _ = slots for the arguments). >>>>>>> >>>>>>> What do you think? >>>>>>> >>>>>>> Best regards >>>>>>> B.D. >>>>>>> >>>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>>> For Developers, A Lot Can Happen In A Second. >>>>>>> Boundary is the first to Know...and Tell You. >>>>>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >>>>>>> http://p.sf.net/sfu/Boundary-d2dvs2 >>>>>>> _______________________________________________ >>>>>>> ojAlgo-user mailing list >>>>>>> ojA...@li... >>>>>>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> For Developers, A Lot Can Happen In A Second. >>>>>> Boundary is the first to Know...and Tell You. >>>>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >>>>>> http://p.sf.net/sfu/Boundary-d2dvs2 >>>>>> _______________________________________________ >>>>>> ojAlgo-user mailing list >>>>>> ojA...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>>>> >>>>> -- >>>>> NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! >>>>> Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> For Developers, A Lot Can Happen In A Second. >>>>> Boundary is the first to Know...and Tell You. >>>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >>>>> http://p.sf.net/sfu/Boundary-d2dvs2 >>>>> _______________________________________________ >>>>> ojAlgo-user mailing list >>>>> ojA...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>>>> >>>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> For Developers, A Lot Can Happen In A Second. >>>> Boundary is the first to Know...and Tell You. >>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >>>> http://p.sf.net/sfu/Boundary-d2dvs2 >>>> _______________________________________________ >>>> ojAlgo-user mailing list >>>> ojA...@li... >>>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>> >>> ------------------------------------------------------------------------------ >>> For Developers, A Lot Can Happen In A Second. >>> Boundary is the first to Know...and Tell You. >>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >>> http://p.sf.net/sfu/Boundary-d2dvs2 >>> _______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>> >>> >> >> >> ------------------------------------------------------------------------------ >> For Developers, A Lot Can Happen In A Second. >> Boundary is the first to Know...and Tell You. >> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >> http://p.sf.net/sfu/Boundary-d2dvs2 >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user |