File: sci_find.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (29 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [stk,txt,top]=sci_find()
// Copyright INRIA
if lhs==1 then
  if stk(top)(3)=='1' then //row vector
    stk=list('find('+stk(top)(1)+')','0','1','?','1')
  elseif stk(top)(4)=='1' then //column vector
    stk=list('find('+stk(top)(1)+')''','0','1','?','1')
  else
    txt=['/'+'/  mtlb_find('+stk(top)(1)+') may be replaced by'
	 '/'+'/  find('+stk(top)(1)+')'' if '+stk(top)(1)+' is not a row vector']
    stk=list('mtlb_find('+stk(top)(1)+')','0','1','?','1')
  end
elseif lhs==2 then
  i=lst(ilst+1)(2)
  j=lst(ilst+2)(2)
  txt='['+j+','+i+'] = find('+stk(top)(1)+');'+i+' = '+i+'(:);'+j+' = '+j+'(:);'
  stk=list(list('?','-2','1','?','1'),list('?','-2','1','?','1'))
else
  i=lst(ilst+1)(2)
  j=lst(ilst+2)(2)
  v=lst(ilst+3)(2)
  temp=gettempvar()
  txt=[temp+' = '+stk(top)(1)+';'
       '['+j+','+i+'] = find('+temp+');'+i+'='+i+'(:);'+j+'='+j+'(:);'
       temp+' = '+temp+'(:)'
       'if '+i+'<>[] then '+v+' = '+temp+'('+i+'+size('+temp+',1)*('+j+'-1)) ;else '+v+' = [],end']
  r=list('?','-2','1','?','1'),
  stk=list(r,r,r)
end