The Sharp Zaurus can be also used as a development machine for BASIC programming. The Bywater BASIC Interpreter can be easily compiled here and it of course runs fast. Both Vim and ZEditor can be used to edit program files (but there is no usefull source code highlighting, unfortunately).

I have tried to run a Gauss solver for a symmetric, positive definite system of linear equations. A full, dense left-side matrix is assumed (actually, only the upper triangle of the matrix is stored).

By the way, an exactly the same code runs flawlesly on the Elektronika MK-90 handheld computer (and thus it may run on the DVK serie of Soviet computers, too). It’s a little bit advanced version of the program that was presented there before some time.

REM Gauss Elimination (full, dense matrix A)
REM Indexes start from 1
REM Only symmetric upper part of matrix is stored and used
REM Uses 1D arrays
REM "A" Indexes: L = I +(J*J-J)/2 -1
REM Data input:
10 DATA 3 1 2 3 2 1 3 3 3 7 5 5 5
20 READ N
30 DIM A(6)
35 DIM B(3)
40 FOR I = 1 TO N
50 FOR J = 1 TO N
55 IF J >= I THEN
58 LET L = I +(J*J-J)/2 -1
60 READ A(L)
65 ELSE
66 READ C
67 END IF
70 NEXT J
80 NEXT I
90 FOR I = 0 TO N-1 STEP 1
95 READ B(I)
100 NEXT I
REM Control print of data:
140 FOR I = 1 TO N
150 FOR J = 1 TO N
155 LET L = I +(J*J-J)/2
160 PRINT A(L);
170 NEXT J
175 PRINT " |";B(I-1)
180 NEXT I
REM Forward run:
300 FOR K = 1 TO N-1
310 FOR I = K+1 TO N
311 LET L = K + (I*I-I)/2 -1
312 LET M = K + (K*K-K)/2 -1
320 LET C = A(L)/A(M)
330 FOR J = I TO N
331 LET L = I +(J*J-J)/2 -1
332 LET M = K +(J*J-J)/2 -1
340 LET A(L) = A(L) - C*A(M)
350 NEXT J
360 LET B(I-1) = B(I-1) - C*B(K-1)
370 NEXT I
380 NEXT K
385 LET L = N +(N*N-N)/2 -1
390 LET B(N-1) = B(N-1) / A(L)
REM Backward run:
400 FOR I = N-1 TO 1 STEP -1
410 LET S = 0
420 FOR J = I+1 TO N
421 LET L = I +(J*J-J)/2 -1
430 LET S = S + A(L) * B(J-1)
440 NEXT J
441 LET L = I +(I*I-I)/2 -1
450 LET B(I-1) = (B(I-1)-S)/A(L)
460 NEXT I
REM Results:
500 PRINT "Results:"
510 FOR I = 0 TO N-1
520 PRINT B(I)
530 NEXT I

The input data hare hard-coded in the `DATA` statement, sorry for that. The first value is number of equations, followed by the matrix data (row by row) and the the right-hand vector is located.

### Like this:

Like Loading...

*Related*