source: issm/branches/trunk-jpl-damage/src/m/model/MatlabFuncs.py@ 12878

Last change on this file since 12878 was 12878, checked in by cborstad, 13 years ago

merged trunk-jpl into trunk-jpl-damage through revision 12877

File size: 675 bytes
Line 
1def strcmp(s1,s2):
2
3 if s1 == s2:
4 return True
5 else:
6 return False
7
8def strncmp(s1,s2,n):
9
10 if s1[0:n] == s2[0:n]:
11 return True
12 else:
13 return False
14
15def strcmpi(s1,s2):
16
17 if s1.lower() == s2.lower():
18 return True
19 else:
20 return False
21
22def strncmpi(s1,s2,n):
23
24 if s1.lower()[0:n] == s2.lower()[0:n]:
25 return True
26 else:
27 return False
28
29def ismember(a,s):
30 import numpy
31
32 if not isinstance(s,(tuple,list,dict,numpy.ndarray)):
33 s=[s]
34
35 if not isinstance(a,(tuple,list,dict,numpy.ndarray)):
36 a=[a]
37
38 if not isinstance(a,numpy.ndarray):
39 b=[item in s for item in a]
40
41 else:
42 b=numpy.empty_like(a)
43 for i,item in enumerate(a.flat):
44 b.flat[i]=item in s
45
46 return b
47
Note: See TracBrowser for help on using the repository browser.