bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] tensor product


From: Fausto Saporito
Subject: Re: [Bug-apl] tensor product
Date: Wed, 20 May 2015 16:52:21 +0200

Hello all,

thanks for the clarification.
Often it's called tensor product in several places on the web, for
this reason my wrong assumption.

regards,
Fausto


2015-05-20 16:08 GMT+02:00 Jay Foad <address@hidden>:
> (Forgot to cc the list.)
>
> ---------- Forwarded message ----------
> From: Jay Foad <address@hidden>
> Date: 20 May 2015 at 14:55
> Subject: Re: [Bug-apl] tensor product
> To: Fausto Saporito <address@hidden>
>
>
> "Why" does it give a multidimensional result? Because that's the way
> it's defined in APL. APL has generalised outer product in a way that
> works very well with multi-dimensional arrays. The Kronecker product
> is a different generalisation, which is useful when you're restricted
> to matrices.
>
> Here's a way to get the Kronecker product in APL, using the example
> from wikipedia (http://en.wikipedia.org/wiki/Kronecker_product):
>
>       kron←{((⍴⍺)+⍴⍵)⍴1 3 2 4⍉⍺∘.×⍵}
>      ⊢a←2 2⍴1 2 3 4
> 1 2
> 3 4
>       ⊢b←2 2⍴0 5 6 7
> 0 5
> 6 7
>       a kron b
>  0  5  0 10
>  6  7 12 14
>  0 15  0 20
> 18 21 24 28
>
> Jay.
>
> On 20 May 2015 at 14:31, Fausto Saporito <address@hidden> wrote:
>> Hello all,
>>
>> I don't understand why the tensor product in APL (∘.×) between two
>> matrices, gives a multidimensional array as result.
>>
>> From linear algebra, tensor product (or kronecker product) gives a
>> matrix as result,
>>
>> for example
>>
>> if I2 is identity matrix
>>
>> 1 0
>> 0 1
>>
>> I2 (tensor product) I2 gives
>>
>> 1 0 0 0
>> 0 1 0 0
>> 0 0 1 0
>> 0 0 0 1
>>
>> instead if I use the APL operator I have :
>>
>> 1 0
>> 0 1
>>
>> 0 0
>> 0 0
>>
>>
>> 0 0
>> 0 0
>>
>> 1 0
>> 0 1
>>
>> the result is correct but why the shape is different ?
>>
>> Is there a way to have a behaviour similar to linear algebra result ?
>>
>> I wrote a generic tensor product function, but I'm not happy because
>> it uses loops and I don't like APL with loops :) but I didn't figure
>> out a loopless solution.
>>
>> thanks,
>> Fausto
>>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]