{"id":18854373,"url":"https://github.com/urbanjost/m_matrix","last_synced_at":"2026-02-05T14:30:18.657Z","repository":{"id":117558189,"uuid":"358730036","full_name":"urbanjost/M_matrix","owner":"urbanjost","description":"interact with your Fortran program with a matlab-like scripting language","archived":false,"fork":false,"pushed_at":"2024-10-07T12:31:47.000Z","size":30450,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T18:28:12.423Z","etag":null,"topics":["array","embeddable","fortran","fortran-package-manager","fpm","inspection","mathematics"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urbanjost.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-16T22:05:16.000Z","updated_at":"2024-10-07T12:31:52.000Z","dependencies_parsed_at":"2024-12-30T18:37:43.618Z","dependency_job_id":null,"html_url":"https://github.com/urbanjost/M_matrix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_matrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_matrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_matrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_matrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbanjost","download_url":"https://codeload.github.com/urbanjost/M_matrix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239793065,"owners_count":19697893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","embeddable","fortran","fortran-package-manager","fpm","inspection","mathematics"],"created_at":"2024-11-08T03:48:03.418Z","updated_at":"2026-02-05T14:30:18.587Z","avatar_url":"https://github.com/urbanjost.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# M_matrix\n\nThis module contains the lala(Los Alamos Linear Algebra) procedure,\nwhich allows for interacting with a Fortran program using Matlab or\nOctave-like commands.  It is also usable as a simple one-line language.\nIt is a still being modernized, but is already useful.\n\nlala(3f) is usable as a simple embedded language. In addition it\nprovides a common interface for \n\n  + self-describing configuration files including expressions,\n    conditional branches and loops\n  + creating points in programs where data can be interactively inspected and \n    changed.\n  + data files that can contain expressions\n  + transferring data between programs \n  + a unit testing and macro-level timing tool.\n\nSupporting functionality includes\n\n  + input files may call additional external files \n\n  + you can create a journal of the commands used and replay them.\n\n  + there is a built-in command history utility that lets you recall,\n    edit, and save your command history when using interactive mode.\n\n  + a built-in help utility describes the many matrix and math functions\n    available.\n\n  + a custom routine may be called via the user(..) function in lala(3f).\n\nA stand-alone program is included that lets you use lala(3f) as a powerful\njournaling calculator and to test and create input files.\n\nIn interactive mode you can browse the user manual via the \"help\" command\nand even view Fortran intrinsic documentation via the \"fhelp\" command.\n\nIt was originally based on some **very** old code that still requires\nsome major refactoring, Participants in modernizing the code are welcome.\n\nlala(1) is quite flexible as a testing framework for Linear Algebra\nlibraries in particular.\n\nAny and all feedback is appreciated.\n\n\u003c!--\n + How important is it to be compatible with Matlab or Octave or Fortran? \n + would a pure functional version be preferred?\n + would dynamic loading of external routines be an important addition?\n\nI do not plan on extending this to allow for creating functions at this\npoint, which would be required to turn it into a more powerful program,\nbut do plan on making it easy to extend with custom math-based procedures\nand using modern Fortran features to make it more maintainable.\n\nMy primary interest is in making it into a tool for interacting with\nFortran programs.\n\nlala(1) is not intrinsically hierarchial nor does it directly support\ncompound types\n --\u003e\n## Simple Configuration File Example\n\nGiven a simple configuration file similiar to a NAMELIST, YAML, JSON,\nINI, CUE, XML or TOML file ...\n```text\n// a simple string\ntitle='this is my title'\n// a numeric value (note use of expression)\npi=4*atan(1)\n// a table of numeric values\ntable=[ \n1.0000  5.0000     3.0000000   ;\n4.0000  2.0000     6.0000000   ;\n1.0000  10.000     45.000000   ;\n10.000  20.000     45.000000   ;\n2.0000  2.0e2     15.000000    ;\n20.345  20.000     15.000000   ;\n30.000  30000.     0.00000000  ;\n4.0000  30.044400  -10.000     ;\n40.000  30.555500  -10.000     ;\n4.0000  30.044400  -10.000     ;\n40.000  30.555500  -10.000     ;\n]\n```\n## Loading a Configuration File\n\nA simple program can read the config file, and then transfer\nvalues to the calling program:\n```fortran\nprogram config\nuse M_matrix, only : lala, get_from_lala, put_into_lala\nimplicit none\n\n! variables to read from config file\nreal,allocatable             :: table(:,:)\ncharacter(len=:),allocatable :: title\nreal                         :: pi\n\ncharacter(len=*),parameter   :: gen='(*(g0,1x))'\ninteger                      :: i\ninteger                      :: ierr\n\n   ! read config file\n   call lala(\"semi;exec('data/xin');return\")\n\n   ! transfer LALA values to the program\n   call get_from_lala('table',table,ierr) ! get the array as a REAL array\n   call get_from_lala('pi',pi,ierr)\n   call get_from_lala('title',title,ierr)\n\n   ! use values in user program\n   write(*,gen)'in calling program table shape =',shape(table)\n   write(*,gen)(table(i,:),new_line('A'),i=1,size(table,dim=1))\n   write(*,*)'title=',title\n   write(*,*)'pi=',PI\nend program config\n```\nExpected output:\n```text\nin calling program table shape = 11 3\n1.00000000 5.00000000 3.00000000 \n 4.00000000 2.00000000 6.00000000 \n 1.00000000 10.0000000 45.0000000 \n 10.0000000 20.0000000 45.0000000 \n 2.00000000 200.000000 15.0000000 \n 20.3449993 20.0000000 15.0000000 \n 30.0000000 30000.0000 0.00000000 \n 4.00000000 30.0443993 -10.0000000 \n 40.0000000 30.5555000 -10.0000000 \n 4.00000000 30.0443993 -10.0000000 \n 40.0000000 30.5555000 -10.0000000 \n\n title=this is my title\n pi=   3.14159274    \n```\nThe biggest advantage lala(3f) provides over most other configuration files\nis that expressions, conditionals, and inclusion of other files are supported.\nBasically, your configuration file becomes embeddable code.\n\nNote the (included) lala(1) program can read any such configuration file and\nlet you inspect the values.\n\n\n## Interacting With User Programs\n\nA program can pass data back and forth to lala(3f), execute files, and\nallow the user to interactively examine, save, change and reload data\nback to the calling program ...\n\n```fortran\n    program demo_lala\n    use M_matrix, only : lala, put_into_lala, get_from_lala, ifin_lala\n    !real,allocatable             :: r\n    !complex,allocatable          :: cvec(:)\n    integer,allocatable          :: iarr(:,:)\n    character(len=:),allocatable :: t(:)\n    integer                      :: ierr\n\n    ! store some data into lala(3)\n    call put_into_lala('A',[1,2,3,4,5]*10.5,ierr)\n    write(*,*)'is A defined in LALA?',ifin_lala('A')\n    call lala('A/2.0')\n \n    ! pass some commands to lala(3f)\n    call lala([character(len=80) :: \u0026\n    \u0026'PI=atan(1)*4               ', \u0026\n    \u0026'mytitle=\"this is my title\";', \u0026\n    \u0026'littlearray=\u003c              ', \u0026\n    \u0026'   1 2 3;                  ', \u0026\n    \u0026'   4 5 6;                  ', \u0026\n    \u0026'   7 8 9;                  ', \u0026\n    \u0026'\u003e                          ', \u0026\n    \u0026'S=sum(A)                   ', \u0026\n    \u0026'I=inv(littlearray);        ', \u0026\n    \u0026'B=littlearray*sin(PI/3)    ', \u0026\n    \u0026'save(\"keepB\",B)            ', \u0026\n    \u0026''])\n\n    ! read a file containing lala(3f) commands\n    call lala('exec(\"mycommands\")')\n\n    ! interactively interact with lala(3f) interpreter\n    call lala() \n\n    ! return values to calling program\n    call get_from_lala('littlearray',iarr,ierr)\n    write(*,'(a)')'IN CALLING PROGRAM IARR='\n    write(*,'(1x,*(g0,1x))')(IARR(i,:),new_line('A'),i=1,size(iarr,dim=1))\n\n    call get_from_lala('mytitle',t,ierr)\n    write(*,*)'IN CALLING PROGRAM T=',t\n\n    end program demo_lala\n```\n\nInstallation requires fpm(1):\n\ndownload the github repository and build it with \nfpm ( as described at [Fortran Package Manager](https://github.com/fortran-lang/fpm) )\n   \n```bash\n   git clone https://github.com/urbanjost/M_matrix.git\n   cd M_matrix\n   fpm run\n```\n   \nor list it as a dependency in the fpm.toml project file ...\n   \n```toml\n        [dependencies]\n        M_matrix        = { git = \"https://github.com/urbanjost/M_matrix.git\" }\n```\n---\n![docs](docs/images/docs.gif)\n---\n\n## Documentation \n\n### User\n\n - call lala(3f) interactively and enter \"help manual\" to browse the \n [entire user manual](https://urbanjost.github.io/M_matrix/userguide.txt)\n\n - An [index](https://urbanjost.github.io/M_matrix/man3.html) to HTML versions\n   of the man-pages included in the distribution.\n\n### Developer Documentation\n\u003c!--\n### doxygen\n\n- [doxygen(1) output](https://urbanjost.github.io/M_attr/doxygen_out/html/index.html).\n\n### ford\n--\u003e\n\n- [ford(1) output](https://urbanjost.github.io/M_matrix/fpm-ford/index.html).\n\n\n[CHANGELOG](CHANGELOG.md)\n\n--\n![demos](docs/images/demo.gif)\n---\n\n### Example input files\n\n#### avg\n```text\n            for i = 2:2:n, for j = 2:2:n, t = (a(i-1,j-1)+a(i-1,j)+a(i,j-1)+a(i,j))/4; ...\n               a(i-1,j-1) = t; a(i,j-1) = t; a(i-1,j) = t; a(i,j) = t;\n```\n\n#### cdiv\n```text\n            // ======================================================\n            // cdiv\n            a=sqrt(random(8)\n               ar = real(a); ai = imag(a); br = real(b); bi = imag(b);\n               p = bi/br;\n               t = (ai - p*ar)/(br + p*bi);\n               cr = p*t + ar/br;\n               ci = t;\n               p2 = br/bi;\n               t2 = (ai + p2*ar)/(bi + p2*br);\n               ci2 = p2*t2 - ar/bi;\n               cr2 = t2;\n               s = abs(br) + abs(bi);\n               ars = ar/s;\n               ais = ai/s;\n               brs = br/s;\n               bis = bi/s;\n               s = brs**2 + bis**2;\n               cr3 = (ars*brs + ais*bis)/s;\n               ci3 = (ais*brs - ars*bis)/s;\n               \u003ccr ci; cr2 ci2; cr3 ci3\u003e\n            // ======================================================\n```\n\n#### exp\n```text\n            t = 0*x + eye; s = 0*eye(x); n = 1;\n            while abs(s+t-s) \u003e 0, s = s+t, t = x*t/n, n = n + 1\n```\n\n#### four\n```text\n            n\n            pi = 4*atan(1);\n            i = sqrt(-1);\n            w = exp(2*pi*i/n);\n            F = \u003c\u003e;\n            for k = 1:n, for j = 1:n, F(k,j) = w**((j-1)*(k-1));\n            F = F/sqrt(n);\n            alfa = r*pi;\n            rho = exp(i*alfa);\n            S = log(rho*F)/i - alfa*EYE;\n            serr = norm(imag(S),1);\n            S = real(S);\n            serr = serr + norm(S-S',1)\n            S = (S + S')/2;\n            ferr = norm(F-exp(i*S),1)\n```\n\n#### gs\n```text\n            for k = 1:n, for j = 1:k-1, d = x(k,:)*x(j,:)'; x(k,:) = x(k,:) - d*x(j,:); ...\n               end, s = norm(x(k,:)), x(k,:) = x(k,:)/s;\n```\n\n#### jacobi\n```text\n            \u003cn, n\u003e = shape(A);\n            X = eye(n);\n            anorm = norm(A,'fro');\n            cnt = 1;\n            while cnt \u003e 0,...\n              cnt = 0;...\n              for p = 1:n-1,...\n                for q = p+1:n,...\n                  if anorm + abs(a(p,q)) \u003e anorm,...\n                    cnt = cnt + 1;...\n                    exec('jacstep');...\n                  end,...\n                end,...\n              end,...\n              display(rat(A)),...\n            end\n```\n\n#### jacstep\n```text\n               d = (a(q,q)-a(p,p))*0.5/a(p,q);\n               t = 1/(abs(d)+sqrt(d*d+1));\n               if d \u003c 0, t = -t; end;\n               c = 1/sqrt(1+t*t);  s = t*c;\n               R = eye(n); r(p,p)=c; r(q,q)=c; r(p,q)=s; r(q,p)=-s;\n               X = X*R;\n               A = R'*A*R;\n```\n\n#### kron\n```text\n            //  C = Kronecker product of A and B\n            \u003cm, n\u003e = shape(A);\n            for i = 1:m, ...\n               ci = a(i,1)*B; ...\n               for j = 2:n, ci = \u003cci a(i,j)*B\u003e; end ...\n               if i = 1, C = ci; else, C = \u003cC; ci\u003e;\n```\n\n#### lanczos\n```text\n            \u003cn,n\u003e = shape(A);\n            q1 = rand(n,1);\n            ort\n            alfa = \u003c\u003e; beta = \u003c\u003e;\n            q = q1/norm(q1); r = A*q(:,1);\n            for j = 1:n, exec('lanstep',0);\n```\n\n#### lanstep\n```text\n            alfa(j) = q(:,j)'*r;\n            r = r - alfa(j)*q(:,j);\n            if ort \u003c\u003e 0, for k = 1:j-1, r = r - r'*q(:,k)*q(:,k);\n            beta(j) = norm(r);\n            q(:,j+1) = r/beta(j);\n            r = A*q(:,j+1) - beta(j)*q(:,j);\n            if j \u003e 1, T = diag(beta(1:j-1),1); T = diag(alfa) + T + T'; eig(T)\n```\n\n#### mgs\n```text\n            for k = 1:n, s = norm(x(k,:)), x(k,:) = x(k,:)/s; ...\n               for j = k+1:n, d = x(j,:)*x(k,:)'; x(j,:) = x(j,:) - d*x(k,:);\n```\n\n#### net\n```text\n            C = \u003c\n            1   2   15  .   .   .\n            2   1   3   .   .   .\n            3   2   4   11  .   .\n            4   3   5   .   .   .\n            5   4   6   7   .   .\n            6   5   8   .   .   .\n            7   5   9   30  .   .\n            8   6   9   10  11  .\n            9   7   8   30  .   .\n            10  8   12  30  31  34\n            11  3   8   12  13  .\n            12  10  11  34  36  .\n            13  11  14  .   .   .\n            14  13  15  16  38  .\n            15  1   14  .   .   .\n            16  14  17  20  35  37\n            17  16  18  .   .   .\n            18  17  19  .   .   .\n            19  18  20  .   .   .\n            20  16  19  21  .   .\n            21  20  22  .   .   .\n            22  21  23  .   .   .\n            23  22  24  35  .   .\n            24  23  25  39  .   .\n            25  24  .   .   .   .\n            26  27  33  39  .   .\n            27  26  32  .   .   .\n            28  29  32  .   .   .\n            29  28  30  .   .   .\n            30  7   9   10  29  .\n            31  10  32  .   .   .\n            32  27  28  31  34  .\n            33  26  34  .   .   .\n            34  10  12  32  33  35\n            35  16  23  34  36  .\n            36  12  35  38  .   .\n            37  16  38  .   .   .\n            38  14  36  37  .   .\n            39  24  26  .   .   .\n            \u003e;\n            \u003cn, m\u003e = shape(C);\n            A = 0*ones(n,n);\n            for i=1:n, for j=2:m, k=c(i,j); if k\u003e0, a(i,k)=1;\n            check = norm(A-A',1), if check \u003e 0, quit\n            \u003cX,D\u003e = eig(A+eye);\n            D = diag(D);  D = D(n:-1:1)\n            X = X(:,n:-1:1);\n            \u003cx(:,1)/sum(x(:,1)) x(:,2) x(:,3) x(:,19)\u003e\n```\n\n#### pascal\n```text\n            //Generate next Pascal matrix\n            \u003ck,k\u003e = shape(L);\n            k = k + 1;\n            L(k,1:k) = \u003cL(k-1,:) 0\u003e + \u003c0 L(k-1,:)\u003e;\n```\n\n#### pdq\n```text\n            alfa = \u003c\u003e; beta = 0; q = \u003c\u003e; p = p(:,1)/norm(p(:,1));\n            t = A'*p(:,1);\n            alfa(1) = norm(t);\n            q(:,1) = t/alfa(1);\n            X = p(:,1)*(alfa(1)*q(:,1))'\n            e(1) = norm(A-X,1)\n            for j = 2:r, exec('pdqstep',ip); ...\n               X = X + p(:,j)*(alfa(j)*q(:,j)+beta(j)*q(:,j-1))', ...\n               e(j) = norm(A-X,1)\n```\n\n#### pdqstep\n```text\n            t = A*q(:,j-1) - alfa(j-1)*p(:,j-1);\n               if ort\u003e0, for i = 1:j-1, t = t - t'*p(:,i)*p(:,i);\n            beta(j) = norm(t);\n            p(:,j) = t/beta(j);\n            t = A'*p(:,j) - beta(j)*q(:,j-1);\n               if ort\u003e0, for i = 1:j-1, t = t - t'*q(:,i)*q(:,i);\n            alfa(j) = norm(t);\n            q(:,j) = t/alfa(j);\n```\n\n#### pop\n```text\n            y = \u003c 75.995   91.972  105.711  123.203   ...\n                 131.669  150.697  179.323  203.212\u003e'\n            t = \u003c 1900:10:1970 \u003e'\n            t = (t - 1940*ones(t))/40;   \u003ct y\u003e\n            n = 8;  A(:,1) = ones(t);  for j = 2:n, A(:,j) = t .* A(:,j-1);\n            A\n            c = A\\y\n```\n\n#### qr\n```text\n            scale = s(m);\n            sm = s(m)/scale; smm1 = s(m-1)/scale; emm1 = e(m-1)/scale;\n            sl = s(l)/scale; el = e(l)/scale;\n            b = ((smm1 + sm)*(smm1 - sm) + emm1**2)/2;\n            c = (sm*emm1)**2;\n            shift = sqrt(b**2+c); if b \u003c 0, shift = -shift;\n            shift = c/(b + shift)\n            f = (sl + sm)*(sl-sm) - shift\n            g = sl*el\n            for k = l: m-1, exec('qrstep',ip)\n            e(m-1) = f\n```\n\n#### qrstep\n```text\n            exec('rot');\n            if k \u003c\u003e l, e(k-1) = f\n            f = cs*s(k) + sn*e(k)\n            e(k) = cs*e(k) - sn*s(k)\n            g = sn*s(k+1)\n            s(k+1) = cs*s(k+1)\n            exec('rot');\n            s(k) = f\n            f = cs*e(k) + sn*s(k+1)\n            s(k+1) = -sn*e(k) + cs*s(k+1)\n            g = sn*e(k+1)\n            e(k+1) = cs*e(k+1)\n```\n\n#### rho\n```text\n            //Conductivity example.\n            //Parameters ---\n               rho       //radius of cylindrical inclusion\n               n         //number of terms in solution\n               m         //number of boundary points\n            //initialize operation counter\n               flop = \u003c0 0\u003e;\n            //initialize variables\n               m1 = round(m/3);   //number of points on each straight edge\n               m2 = m - m1;       //number of points with Dirichlet conditions\n               pi = 4*atan(1);\n            //generate points in Cartesian coordinates\n               //right hand edge\n               for i = 1:m1, x(i) = 1; y(i) = (1-rho)*(i-1)/(m1-1);\n               //top edge\n               for i = m2+1:m, x(i) = (1-rho)*(m-i)/(m-m2-1); y(i) = 1;\n               //circular edge\n               for i = m1+1:m2, t = pi/2*(i-m1)/(m2-m1+1); ...\n                  x(i) = 1-rho*sin(t);  y(i) = 1-rho*cos(t);\n            //convert to polar coordinates\n               for i = 1:m-1, th(i) = atan(y(i)/x(i));  ...\n                  r(i) = sqrt(x(i)**2+y(i)**2);\n               th(m) = pi/2;  r(m) = 1;\n            //generate matrix\n               //Dirichlet conditions\n               for i = 1:m2, for j = 1:n, k = 2*j-1; ...\n                  a(i,j) = r(i)**k*cos(k*th(i));\n               //Neumann conditions\n               for i = m2+1:m, for j = 1:n, k = 2*j-1; ...\n                  a(i,j) = k*r(i)**(k-1)*sin((k-1)*th(i));\n            //generate right hand side\n               for i = 1:m2, b(i) = 1;\n               for i = m2+1:m, b(i) = 0;\n            //solve for coefficients\n               c = A$b\n            //compute effective conductivity\n               c(2:2:n) = -c(2:2:n)\n               sigma = sum(c)\n            //output total operation count\n               ops = flop(2)\n```\n\n#### rogers.exec\n```text\n            exec('d.boug');                        // reads data\n            \u003cg,k\u003e = shape(p);               // p is matrix of gene frequencies\n            wv = ncen/sum(ncen);           // ncen contains population sizes\n            pbar = wv*p;                   // weighted average of p\n            p = p - ones(g,1)*pbar;        // deviations from mean\n            p = sqrt(diag(wv)) * p;        // weight rows of p by sqrt of pop size\n            h = diag(pbar); h = h*(eye-h); // diagonal contains binomial variance: p*(1-p)\n            r = p*inv(h)*p'/k;             // normalized covariance matrix\n            eig(r)'\n```\n\n#### rosser\n```text\n            A  = \u003c\n              611.  196. -192.  407.   -8.  -52.  -49.   29.\n              196.  899.  113. -192.  -71.  -43.   -8.  -44.\n             -192.  113.  899.  196.   61.   49.    8.   52.\n              407. -192.  196.  611.    8.   44.   59.  -23.\n               -8.  -71.   61.    8.  411. -599.  208.  208.\n              -52.  -43.   49.   44. -599.  411.  208.  208.\n              -49.   -8.    8.   59.  208.  208.   99. -911.\n               29.  -44.   52.  -23.  208.  208. -911.   99.  \u003e;\n```\n\n#### rot\n```text\n            // subexec rot(f,g,cs,sn)\n                  rho = g; if abs(f) \u003e abs(g), rho = f;\n                  cs = 1.0; sn = 0.0; z = 1.0;\n                  r = norm(\u003cf g\u003e); if rho \u003c 0, r = -r; r\n                  if r \u003c\u003e 0.0, cs = f/r\n                  if r \u003c\u003e 0.0, sn = g/r\n                  if abs(f) \u003e abs(g), z = sn;\n                  if abs(g) \u003e= abs(f), if cs \u003c\u003e 0, z = 1/cs;\n                  f = r;\n                  g = z;\n```\n#### rqi\n```text\n            rho = (x'*A*x)\n            x = (A-rho*eye)\\x;\n            x = x/norm(x)\n```\n#### setup\n```text\n            diary('xxx')\n            !tail -f xxx \u003e /dev/tty1 \u0026\n            !tail -f xxx \u003e /dev/tty2 \u0026\n```\n#### sigma\n```text\n            RHO = .5  M = 20  N = 10   SIGMA =  1.488934271883534\n            RHO = .5  M = 40  N = 20   SIGMA =  1.488920312974229\n            RHO = .5  M = 60  N = 30   SIGMA =  1.488920697912116\n```\n#### strut.mat\n```text\n            // Structure problem, Forsythe, Malcolm and Moler, p. 62\n            s =  sqrt(2)/2;\n            A = \u003c\n            -s  .  .  1  s   .  .  .  .  .  .  .  .  .  .  .  .\n            -s  . -1  . -s   .  .  .  .  .  .  .  .  .  .  .  .\n             . -1  .  .  .   1  .  .  .  .  .  .  .  .  .  .  .\n             .  .  1  .  .   .  .  .  .  .  .  .  .  .  .  .  .\n             .  .  . -1  .   .  .  1  .  .  .  .  .  .  .  .  .\n             .  .  .  .  .   . -1  .  .  .  .  .  .  .  .  .  .\n             .  .  .  . -s -1  .  .  s  1  .  .  .   .  .  .  .\n             .  .  .  .  s   .  1  .  s  .  .  .  .  .  .  .  .\n             .  .  .  .  .   .  . -1 -s  .  .  1  s  .  .  .  .\n             .  .  .  .  .   .  .  . -s  . -1  . -s  .  .  .  .\n             .  .  .  .  .   .  .  .  . -1  .  .  .  1  .  .  .\n             .  .  .  .  .   .  .  .  .  .  1  .  .  .  .  .  .\n             .  .  .  .  .   .  .  .  .  .  . -1  .  .  .  s  .\n             .  .  .  .  .   .  .  .  .  .  .  .  .  . -1 -s  .\n             .  .  .  .  .   .  .  .  .  .  .  . -s -1  .  .  1\n             .  .  .  .  .   .  .  .  .  .  .  .  s  .  1  .  .\n             .  .  .  .  .   .  .  .  .  .  .  .  .  .  . -s -1\u003e;\n            b = \u003c\n             .  .  . 10  .   .  . 15  .  .  .  .  .  .  . 10  .\u003e';\n```\n#### test1\n```text\n            // -----------------------------------------------------------------\n            // start a new log file\n            sh rm -fv log.txt\n            diary('log.txt')\n            // -----------------------------------------------------------------\n            titles=\u003c'GNP deflator'\n             'GNP         '\n             'Unemployment'\n             'Armed Force '\n             'Population  '\n             'Year        '\n             'Employment  '\u003e;\n            data = ...\n            \u003c 83.0  234.289  235.6  159.0  107.608  1947  60.323\n              88.5  259.426  232.5  145.6  108.632  1948  61.122\n              88.2  258.054  368.2  161.6  109.773  1949  60.171\n              89.5  284.599  335.1  165.0  110.929  1950  61.187\n              96.2  328.975  209.9  309.9  112.075  1951  63.221\n              98.1  346.999  193.2  359.4  113.270  1952  63.639\n              99.0  365.385  187.0  354.7  115.094  1953  64.989\n             100.0  363.112  357.8  335.0  116.219  1954  63.761\n             101.2  397.469  290.4  304.8  117.388  1955  66.019\n             104.6  419.180  282.2  285.7  118.734  1956  67.857\n             108.4  442.769  293.6  279.8  120.445  1957  68.169\n             110.8  444.546  468.1  263.7  121.950  1958  66.513\n             112.6  482.704  381.3  255.2  123.366  1959  68.655\n             114.2  502.601  393.1  251.4  125.368  1960  69.564\n             115.7  518.173  480.6  257.2  127.852  1961  69.331\n             116.9  554.894  400.7  282.7  130.081  1962  70.551\u003e;\n            short\n            X = data;\n            \u003cn,p\u003e = shape(X)\n            mu = ones(1,n)*X/n\n            X = X - ones(n,1)*mu;  X = X/diag(sqrt(diag(X'*X)))\n            corr = X'*X\n            y = data(:,p); X = \u003cones(y) data(:,1:p-1)\u003e;\n            long e\n            beta = X\\y\n            expected = \u003c ...\n               -3.482258634594421D+03\n                1.506187227124484D-02\n               -3.581917929257409D-02\n               -2.020229803816908D-02\n               -1.033226867173703D-02\n               -5.110410565317738D-02\n                1.829151464612817D+00\n            \u003e\n            disp('EXPE and BETA should be the same')\n```\n#### tryall\n```text\n            diary('log.txt')\n            a=magic(8)\n            n=3\n            exec('avg')\n            b=random(8,8)\n            exec('cdiv')\n            exec('exp')\n            exec('four')\n            exec('gs')\n            exec('jacobi')\n            // jacstep\n            exec('kron')\n            exec('lanczos')\n            // lanstep\n            exec('longley')\n            exec('mgs')\n            exec('net')\n            exec('pascal')\n            exec('pdq')\n            // pdqstep\n            exec('pop')\n            exec('qr')\n            // qrstep\n            exec('rho')\n            exec('rosser')\n            // rot\n            exec('rqi')\n            exec('setup')\n            exec('sigma')\n            exec('strut.mat')\n            exec('w5')\n            exec('rogers.exec\n            exec('rogers.load\n```\n#### w5\n```text\n            w5    = \u003c\n                      1.          1.          0.          0.          0.\n                    -10.          1.          1.          0.          0.\n                     40.          0.          1.          1.          0.\n                   -205.          0.          0.          1.          1.\n                   1024.          0.          0.          0.         -4.\n                     \u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fm_matrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbanjost%2Fm_matrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fm_matrix/lists"}