Skip to content

Commit 1748134

Browse files
committed
up
1 parent 44bcad9 commit 1748134

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

k+/blas.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ uint64_t gemv(uint64_t L){ //y:gemv[a;A;rA;op;b;y;x]
4747
}
4848

4949
uint64_t band(uint64_t x){ //symmetric layout only (1 1;2 2 2;3 3 3 3;4 4 4;5 5)
50-
x=Fst(x);if(tp(x)!=Lt)trap();
51-
int32_t m=nn(x),u=m/2;if(!(m&1))trap();
50+
int32_t lu=iL(x,0);x=ati(x,1);if(tp(x)!=Lt)trap();
51+
int32_t m=nn(x),u=m/2;if(!(m&1))trap();lu*=u;
5252
uint64_t d=FZ(ati(rx(x),u));if(tp(x)<16)trap();
5353
int32_t n=nn(d),z=(tp(d)==Zt);
54-
uint64_t r=mk(z?Zt:Ft,n*(m+u)); //additional space for lapack LU
54+
uint64_t r=mk(z?Zt:Ft,n*(m+lu)); //lu: additional space for lapack LU
5555
char*p=M_+(int32_t)r;
5656
const int32_t s=z?4:3;
57-
memset(FK(r),0,(z?16:8)*n*(m+u));
58-
int32_t o=0;for(int32_t i=0;i<m;i++){
57+
memset(FK(r),0,(z?16:8)*n*(m+lu));
58+
int32_t o=lu;for(int32_t i=0;i<m;i++){
5959
uint64_t xi=FZ(ati(rx(x),i));
6060
int32_t nx=nn(xi);
6161
if(nx!=(i<u?n-u+i:n+u-i)||(z&&tp(xi)!=Zt))trap();
6262
int32_t k=nn(ati(rx(x),u));
63-
if(i>u)o++;memcpy(p+(o+(n*(m-1-i))<<s),FK(xi),nx<<s);dx(xi);
63+
if(i>u)o++;memcpy(p+(o+(n*(m+lu-1-i))<<s),FK(xi),nx<<s);dx(xi);
6464
}
6565
dx(x);return r;
6666
}
6767

6868
void blas(void){
69-
reg(band,"band",1); //band matrix from diagonals, e.g. band(3 3 3;1 1 1 1;2 2 2) netlib.org/lapack/lug/node124.html
69+
reg(band,"band",2); //band matrix from diagonals, e.g. band(3 3 3;1 1 1 1;2 2 2) netlib.org/lapack/lug/node124.html
7070
reg(nrm2,"nrm2",1);
7171
reg(asum,"asum",1);
7272
reg(imax,"imax",1);

k+/readme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
# dot[x;y] +/x*y dotc[x;y] +/(conj x)*y scalar product
2020
# gemv[a;A;rA;op;b;y;x] c:fz A:FZ b:fz y:FZ a*A*x+b*y (if b:0, y can be any)
2121
# dbmv[a;A;rA;u;op;b;y;x] band matrix-vector a*A*x+b*y
22-
# band[x] convert list of diagonals to band matrix layout
22+
# band[0;x] convert list of diagonals to band matrix layout, band[1;x] with space for LU
2323
#
24-
# LAPACK
24+
# LAPACK icl.utk.edu/~mgates3/docs/lapack.html
2525
# gesv[A;b] or b,b,.. solve Ax=b, both col-major flat vectors
2626
# gels[n;A;b] or b,b,.. solve Ax=b least squares
2727
#

0 commit comments

Comments
 (0)