(0 { a) *"1 b
10 22 36 52
14 30 48 68
On Monday, April 18, 2016, 'Jon Hough' via Programming <
[email protected]> wrote:
> Thanks,
>
> I was actually just trying that. Problem is, it has a dangling dimension
> (shape 1 4 2), which can be removed, but seems a little messy.
>
>
> --------------------------------------------
> On Mon, 4/18/16, EelVex <[email protected] <javascript:;>> wrote:
>
> Subject: Re: [Jprogramming] Simple scalar multiplication of matrices
> To: "Programming forum" <[email protected] <javascript:;>>
> Date: Monday, April 18, 2016, 5:54 PM
>
> Of course, you can still
> go by the dot product. Just don't sum:
>
> a (] . *) |:b
> 10 14
> 22 30
> 36
> 48
> 52 68
>
>
> On Mon, Apr 18, 2016 at 11:49 AM, EelVex <[email protected] <javascript:;>
> >
> wrote:
>
> > If you remove
> the first axis of a you can multiply-1:
> >
> > (,a) *"1 b
> > 10 22 36 52
> > 14 30 48
> 68
> >
> > Do you really
> need a to be 1xn ?
> >
> >
> > On Mon, Apr 18, 2016
> at 11:41 AM, 'Jon Hough' via Programming <
> > [email protected] <javascript:;>>
> wrote:
> >
> >> I am
> sure there is a simple answer to this, but I would like to
> know it.
> >>
> >>
> Say I have two matrices:
> >>
> >> a =: 1 4 $ 1 2 3 4
> >> b =: 2 4 $ 10 11 12 13 14 15 16 17
> >>
> >> and I want to
> multiply a's single row element-wise with each of
> b's rows.
> >> Not matrix
> multiplication, so the resulting matrix should have
> dimensions 2
> >> 4, same as b.
> >>
> >> Obviously a *
> b gives a length error,
> >>
> >> So does a *"1 1 b
> >>
> >> My best
> solution is pretty ugly,
> >>
> >> (($b)$,a ) * b
> >>
> >> i.e. reshape
> a so it has the same number of rows as b, which
> duplicates
> >> the items of its top row
> into the second row and then multiply row-wise.
> >>
> >> Is there a
> better way?
> >> Incidentally, isn't
> a*1 1 b a row-to-row multiplication. I thought this
> >> would have worked, and am slightly
> confused why it doesn't.
> >>
> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
> >
> >
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
Sent from Gmail Mobile
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm