/[escript]/trunk/escript/py_src/symbols.py
ViewVC logotype

Contents of /trunk/escript/py_src/symbols.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2344 - (show annotations)
Mon Mar 30 02:13:58 2009 UTC (10 years, 4 months ago) by jfenwick
File MIME type: text/x-python
File size: 3829 byte(s)
Change __url__ to launchpad site

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 ## @file symbols.py
23
24 """
25 some tools supporting the usage of symbols.
26
27 @var __author__: name of author
28 @var __copyright__: copyrights
29 @var __license__: licence agreement
30 @var __url__: url entry point on documentation
31 @var __version__: version
32 @var __date__: date of the version
33 """
34
35 __author__="Lutz Gross, l.gross@uq.edu.au"
36
37 from util import Symbol
38
39 def ScalarSymbol(dim=None):
40 """
41 Returns a rank 0 L{Symbol}.
42
43 @param dim: spatial dimension or an object that has the C{getDim} method
44 defining the spatial dimension. If dim=C{None}, the spatial
45 diminsion of the returned L{Symbol} is undefined.
46 @type dim: C{None}, C{int} or any object with a C{getDim} method
47 @return: a L{Symbol} of rank 0
48 @rtype: L{Symbol}
49 """
50 if hasattr(dim,"getDim"):
51 d=dim.getDim()
52 else:
53 d=dim
54 return Symbol(shape=(),dim=d,args=[])
55
56
57 def VectorSymbol(dim=3):
58 """
59 Returns a vector L{Symbol} of rank 1 and spatial dimension C{dim}.
60
61 @param dim: spatial dimension or an object that has the C{getDim} method
62 defining the spatial dimension
63 @type dim: C{int} or any object with a C{getDim} method
64 @return: a L{Symbol} of shape (C{dim},)
65 @rtype: L{Symbol}
66 """
67 if hasattr(dim,"getDim"):
68 d=dim.getDim()
69 else:
70 d=dim
71 return Symbol(shape=(d,),dim=d,args=[])
72
73 def TensorSymbol(dim=3):
74 """
75 Returns a tensor L{Symbol} of rank 2 and spatial dimension C{dim}.
76
77 @param dim: spatial dimension or an object that has the C{getDim} method
78 defining the spatial dimension
79 @type dim: C{int} or any object with a C{getDim} method
80 @return: a L{Symbol} of shape (C{dim},C{dim})
81 @rtype: L{Symbol}
82 """
83 if hasattr(dim,"getDim"):
84 d=dim.getDim()
85 else:
86 d=dim
87 return Symbol(shape=(d,d),dim=d,args=[])
88
89 def Tensor3Symbol(dim=3):
90 """
91 Returns a tensor L{Symbol} of rank 3 and spatial dimension C{dim}.
92
93 @param dim: spatial dimension or an object that has the C{getDim} method
94 defining the spatial dimension
95 @type dim: C{int} or any object with a C{getDim} method
96 @return: a L{Symbol} of shape (C{dim},C{dim},C{dim})
97 @rtype: L{Symbol}
98 """
99 if hasattr(dim,"getDim"):
100 d=dim.getDim()
101 else:
102 d=dim
103 return Symbol(shape=(d,d,d),dim=d,args=[])
104
105 def Tensor4Symbol(dim=3):
106 """
107 Returns a tensor L{Symbol} of rank 4 and spatial dimension C{dim}.
108
109 @param dim: spatial dimension or an object that has the C{getDim} method
110 defining the spatial dimension
111 @type dim: C{int} or any object with a C{getDim} method
112 @return: a L{Symbol} of shape (C{dim},C{dim},C{dim},C{dim})
113 @rtype: L{Symbol}
114 """
115 if hasattr(dim,"getDim"):
116 d=dim.getDim()
117 else:
118 d=dim
119 return Symbol(shape=(d,d,d,d),dim=d,args=[])
120 #
121 # $Log:$
122 #
123 # vim: expandtab shiftwidth=4:

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26