linear algebra in kdb

Hi everyone,here are several questions about matrix and vector in kdb.How to perform matrix and vector multiplication in kdb?I use wsum: in kdb, for example:q) (2 2 # til 4) wsum: 1 2How to do it smarter?How to perform matrix divide in kdb?I know that there is the function lsq in kdb, butit does not work for the following example:q) (2 8f) lsq (2 2 # `float$ til 4)How to do matrix and matrix multiplication?Is mmu the best way?Thanks for any comments and answers.Kim

To: personal-kdbplus@googlegroups.comX-Mailer: Apple Mail (2.1084)On Aug 20, 2011, at 6:17 AM, kuentang wrote:> How to perform matrix divide in kdb?> I know that there is the function lsq in kdb, but> it does not work for the following example:> q) (2 8f) lsq (2 2 # float$ til 4)lsq requires a matrix on both sides (since 2.6)q)(enlist 2 8f)lsq 2 2#float$til 45 1

Hi Aaron,thx for your reply.And what is the best way to perform matrix vector multiplication?KimAm 21.08.2011 00:58, schrieb Aaron Davies:> On Aug 20, 2011, at 6:17 AM, kuentang wrote:>>> How to perform matrix divide in kdb?>> I know that there is the function lsq in kdb, but>> it does not work for the following example:>> q) (2 8f) lsq (2 2 # float$ til 4)\> lsq requires a matrix on both sides (since 2.6)\>\> q)(enlist 2 8f)lsq 2 2#float$til 4> 5 1>

charset=us-ascii
X-Mailer: iPhone Mail (8F190)
In-Reply-To: <4E50BB74.6050708@vodafone.de>
Message-Id: <806F7213-2887-4971-BFA0-0E619220B44B@gmail.com>
Date: Sun, 21 Aug 2011 07:20:27 -0400
To: “personal-kdbplus@googlegroups.com

Mime-Version: 1.0 (iPhone Mail 8F190)

mmu, but only works on floats and as far as I recall it doesn’t cast for you=
. If you need really fast on int type you might consider c code.

Am 21.08.2011 13:20, schrieb Timothy Rieder:
> mmu, but only works on floats and as far as I recall it doesn’t cast for you. If you need really fast on int type you
As far as i can see mmu works only for vector-matrix-multiplication
enlist[1 2f] mmu (1 2f; 1 2f)

and matrix-matrix-multiplication

(1 2f; 1 2f) mmu (1 2f; 1 2f)

but not for

matrix-vector-multiplication

(1 2f; 1 2f) mmu enlist[1 2f]

So mmu seems not to work for all cases.

> might consider c code.
>
> On Aug 21, 2011, at 4:01 AM, Kim Kuen Tang wrote:
>
>> Hi Aaron,
>>
>> thx for your reply.
>>
>> And what is the best way to perform matrix vector multiplication?
>>
>> Kim
>>
>> Am 21.08.2011 00:58, schrieb Aaron Davies:
>>> On Aug 20, 2011, at 6:17 AM, kuentang wrote:
>>>
>>>> How to perform matrix divide in kdb?
>>>> I know that there is the function lsq in kdb, but
>>>> it does not work for the following example:
>>>> q) (2 8f) lsq (2 2 # float$ til 4)<br>&gt;&gt;&gt; lsq requires a matrix on both sides (since 2.6)<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; q)(enlist 2 8f)lsq 2 2#float$til 4
>>> 5 1
>>>
>> –
>>

Submitted via Google Groups

charset=us-ascii
X-Mailer: iPhone Mail (8F190)
In-Reply-To: <4E50EC0B.2010709@vodafone.de>
Message-Id:
Date: Sun, 21 Aug 2011 07:42:46 -0400
To: “personal-kdbplus@googlegroups.com

Mime-Version: 1.0 (iPhone Mail 8F190)

If it doesn’t work for what you need then write some c code to do what you n=
eed. You can obviously do it in q, but I’m pretty sure the equivalent c code=
will be faster.

>(1 2f; 1 2f) mmu enlist[1 2f]

enlist 1 2f

is not a vector

it is a matrix (of the wrong shape)

?

q)(1 2f;1 2f)$1 2f

5 5f

? Attila