September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,20 @@
var [const] GSL=Import("zklGSL"); // libGSL (GNU Scientific Library)
fcn onGrid(i,j,p,q){ ((0<=i<p) and (0<=j<q)) }
fcn gridResistor(p,q, ai,aj, bi,bj){
n,A := p*q, GSL.Matrix(n,n); // zero filled
foreach i,j in (p,q){
k:=i*q + j;
if(i==ai and j==aj) A[k,k]=1;
else{
c:=0;
if(onGrid(i+1,j, p,q)){ c+=1; A[k, k+q]=-1 }
if(onGrid(i-1,j, p,q)){ c+=1; A[k, k-q]=-1 }
if(onGrid(i, j+1, p,q)){ c+=1; A[k, k+1]=-1 }
if(onGrid(i, j-1, p,q)){ c+=1; A[k, k-1]=-1 }
A[k,k]=c;
}
}
b:=GSL.Vector(n); // zero filled
b[k:=bi*q + bj]=1;
A.AxEQb(b)[k];
}

View file

@ -0,0 +1 @@
gridResistor(10,10, 1,1, 7,6).println();