options echo=2
prefix("basic2.")
$Random.seed_c(57,0,3,0,0,0,49,16,0,0,0,0)	# to initialize at same spot
# test simple matrix, vector, ts stuff
if(all(rev(1:10)==10.:1))"Rev and all seem OK"
rep(c("a,","b","c"),0:2)
rep(3.14159,8)
sort(c(3,1,5,2,4))
split(1:10,c("Odd","Even"))
match(1:5,c(3,4,4,2))
rank(c(1,2,3,3,5))
unique(c(1,2,3,3,1,2,5))
xmat_matrix(rnorm(60),20,3)
round(xmat,1)
t(round(xmat,2))
xmat_cbind(rbind(xmat,c(1,1,1)),rnorm(21))
cor(xmat); cor(xmat,trim=.2)
yvec_rnorm(21)
r_regress(xmat,yvec)
regprt(r,names=encode("X Variable",1:4))
regsum(r)
sum(abs(yvec-r$resid-cbind(1,xmat)%*r$coef))	# should be near zero
twoway(xmat)->t	# should get warning
fit_matrix(t$row,nrow(xmat),ncol(xmat))+matrix(t$col,nrow(xmat),ncol(xmat),byrow=TRUE)+
t$grand
sum(abs(fit+t$resid-xmat))
timeser_ts(1:20,c(1958,3),12)
print(start(timeser),end(timeser),nper(timeser))
print(cbind(time(timeser),cycle(timeser),timeser%mINT),rowlab="")	# no row labels
mm_matrix(runif(16),4,4)
if(any(diag(mm)!=mm[row(mm)==col(mm)]))"We got troubles"
diag(3);diag(diag(mm))
mm[1,3]_NA
replace(mm,3,1,10000000)
append(mm,1:5)	#should end in 1:5 and be a vector, not matrix
pmin(c(1,3,9),c(2,2,20))
pmax(c(1,3,9),c(2,2,20))
min(smooth(1:20)==1:20)	# should be 1
c(229,205,228,233,224,244,229,215,236,293,323,286,
356,158,104,108,108,130,115,154,84,67,43,86,
15,0,0,7,0,2,61,38,166,59,88,111,
114,86,48,95,93,34,139,136,167,23,111)->deposits	# suspended bank deposits
deposits_ts(deposits,start=1921,nper=1)
smooth(deposits)
range(rnorm(1000))
ifelse(runif(10)>.5,"heads","tails")
na(c(1,3,NA,4,3/0))
print(len(xmat),mode(xmat))
prod(1:10)==3628800
l_order(xmat[,1]);print(xmat[l,],rowlab=(1:nrow(xmat))%mCHAR)# first col should be sorted
dput(xmat,file="tttt"); dget("tttt")
# try the mail command to give feedback about the test
!rm tttt
source()	# should exit the file
# so that this line isn't executed
