Adnan,
Please find the answers inline.
> How would I index A so all rows except A[0] could have an operation applied to it?
q)A:4 4#til 16
q)A
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
q)A[1_til count A]
4 5 6 7
8 9 10 11
12 13 14 15
An example of functional amend:
q)@[A;1_til count A;neg]
0 1 2 3
-4 -5 -6 -7
-8 -9 -10 -11
-12 -13 -14 -15
> Also, say I have an list, v, the length of A’s vectors, how would I create a new matrix, X, which contains the first row of A multiplied by each constant in the list?
You can use each-right adverb (http://code.kx.com/wiki/Reference/SlashColon). An example below:
q)v:10 20 30 40
q)v
10 20 30 40
q)A[0]*/:v
0 10 20 30
0 20 40 60
0 30 60 90
0 40 80 120
HTH,
Pawel
2013/10/27 Adnan G <adnan.gazi01@gmail.com>
Say I have a square matrix of numbers assigned to A.
How would I index A so all rows except A[0] could have an operation applied to it?
Also, say I have an list, v, the length of A’s vectors, how would I create a new matrix, X, which contains the first row of A multipled by each constant in the list?
i.e.
X[0] = A[0]*v[0];
X[1] = A[0]*v[1];.
…
X[n] = A[0]*v[n];
I want to do this without a loop, working with an arbitrarily-sized n.
Any help would be appreciated.
Thanks.
–
Submitted via Google Groups