:

## Very slow evaluating matrix computation.

Maple
Hello, I would like to use Maple instead of Matlab, well I rewrite the Matlab code to Maple like following. The output is correct, but it spends more time than in Matlab. Is it possible to rewrite my Maple code to get output faster? ```restart: linearni_model:=proc(beta,sigma) local n1,n2,Y,X,Y1,Y2,se,se2,t1,t2,t3,t4,vbeta,t,si2,e1,e2,e3,e4,Yp,N,s2,n; use Statistics in X:=Matrix([[1, 1, 1, 1, 1], [1, 1, 1, 1, -1], [1, 1, 1, -1, 1], [1, 1, 1, -1, -1], [1, 1, -1, 1, 1], [1, 1, -1, 1, -1], [1, 1, -1, -1, 1], [1, 1, -1, -1, -1], [1, -1, 1, 1, 1], [1, -1, 1, 1, -1], [1, -1, 1, -1, 1], [1, -1, 1, -1, -1], [1, -1, -1, 1, 1], [1, -1, -1, 1, -1], [1, -1, -1, -1, 1], [1, -1, -1, -1, -1]]); n:=16; N := RandomVariable(Normal(0,sigma)): n1:=Sample(N,16); n2:=Sample(N,16): Y:=X.beta: Y:=convert(Y,Vector[row]): Y1 := Y + n1: Y2 := Y + n2: Yp := (Y1 + Y2)/2: e1:=add(Yp[k]*X[k,2]/(n/2),k=1..16): e2:=add(Yp[k]*X[k,3]/(n/2),k=1..16): e3:=add(Yp[k]*X[k,4]/(n/2),k=1..16): e4:=add(Yp[k]*X[k,5]/(n/2),k=1..16): si2:=Vector[row](1..16): si2 := 1/2*map(x->x^2, Y1[1..16]-Y2[1..16]): s2:=add(si2[k],k=1..16)/n: se2 := 4*s2/(2*n): se:=sqrt(se2): t1 := e1/se; t2 := e2/se; t3 := e3/se; t4 := e4/se; t := 2.1199: #% z tabulek k=16, alfa=0,05 #% testy vyznamnosti efektu,1-je vyznamny,0-neni vyznamny vbeta := <0,0,0,0>: if abs(t1)>t then vbeta[1]:=1: end if; if abs(t2)>t then vbeta[2]:=1: end if; if abs(t3)>t then vbeta[3]:=1: end if; if abs(t4)>t then vbeta[4]:=1: end if; end use; return vbeta; end proc: test:=proc(beta, sigma, pocet_opakovani) local i,vyznamnost; vyznamnost := ``` Thank you very much. Vladimir View 551_mapleprimes.mw on MapleNet or Download 551_mapleprimes.mw
View file details

﻿