On Fri, Apr 8, 2016 at 5:11 PM, Charles R Harris <charlesr.har...@gmail.com> wrote:
> > > On Fri, Apr 8, 2016 at 2:52 PM, <josef.p...@gmail.com> wrote: > >> >> >> On Fri, Apr 8, 2016 at 3:55 PM, Charles R Harris < >> charlesr.har...@gmail.com> wrote: >> >>> >>> >>> On Fri, Apr 8, 2016 at 12:17 PM, Chris Barker <chris.bar...@noaa.gov> >>> wrote: >>> >>>> On Fri, Apr 8, 2016 at 9:59 AM, Charles R Harris < >>>> charlesr.har...@gmail.com> wrote: >>>> >>>>> Apropos column/row vectors, I've toyed a bit with the idea of adding a >>>>> flag to numpy arrays to indicate that the last index is one or the other, >>>>> and maybe neither. >>>>> >>>> >>>> I don't follow this. wouldn't it ony be an issue for 1D arrays, rather >>>> than the "last index". Or maybe I'm totally missing the point. >>>> >>>> But anyway, are (N,1) and (1, N) arrays insufficient for representing >>>> column and row vectors for some reason? If not -- then we have a way to >>>> express a column or row vector, we just need an easier and more obvious way >>>> to create them. >>>> >>>> *maybe* we could have actual column and row vector classes -- they >>>> would BE regular arrays, with (1,N) or (N,1) dimensions, and act the same >>>> in every way except their __repr__. and we're provide handy factor >>>> functions for them. >>>> >>>> These were needed to complete the old Matrix class -- which is no >>>> longer needed now that we have @ (i.e. a 2D array IS a matrix) >>>> >>> >>> One problem with that approach is that `vrow @ vcol` has dimension 1 x >>> 1, which is not a scalar. >>> >> >> I think it's not supposed to be a scalar, if @ breaks on scalars >> >> `vrow @ vcol @ a >> > > It's supposed to be a scalar and the expression should be written `vrow @ > vcol * a`, although parens are probably desireable for clarity `(vrow @ > vcol) * a`. > if a is 1d or twod vcol, and vrow and vcol could also be 2d arrays (not a single row or col) this is just a part of a long linear algebra expression 1d dot 1d is different from vrow dot vcol A dot 1d is different from A dot vcol. There intentional differences in the linear algebra behavior of 1d versus a col or row vector. One of those is dropping the extra dimension. We are using this a lot to switch between 1-d and 2-d cases. And another great thing about numpy is that often code immediately generalizes from 1-d to 2d with just some tiny adjustments. (I haven't played with @ yet) I worry that making the 1-d arrays suddenly behave ambiguously as weird 1-d/2-d mixture will make code more inconsistent and more difficult to follow. shortcuts and variations of atleast_2d sound fine, but not implicitly Josef > > Chuck > > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > https://mail.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion