/[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 3911 - (show annotations)
Thu Jun 14 01:01:03 2012 UTC (7 years, 4 months ago) by jfenwick
File MIME type: text/x-python
File size: 3845 byte(s)
Copyright changes
1
2 ########################################################
3 #
4 # Copyright (c) 2003-2012 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-2012 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 `Symbol`.
42
43 :param dim: spatial dimension or an object that has the ``getDim`` method
44 defining the spatial dimension. If dim=``None``, the spatial
45 diminsion of the returned `Symbol` is undefined.
46 :type dim: ``None``, ``int`` or any object with a ``getDim`` method
47 :return: a `Symbol` of rank 0
48 :rtype: `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 `Symbol` of rank 1 and spatial dimension ``dim``.
60
61 :param dim: spatial dimension or an object that has the ``getDim`` method
62 defining the spatial dimension
63 :type dim: ``int`` or any object with a ``getDim`` method
64 :return: a `Symbol` of shape (``dim``,)
65 :rtype: `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 `Symbol` of rank 2 and spatial dimension ``dim``.
76
77 :param dim: spatial dimension or an object that has the ``getDim`` method
78 defining the spatial dimension
79 :type dim: ``int`` or any object with a ``getDim`` method
80 :return: a `Symbol` of shape (``dim``,``dim``)
81 :rtype: `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 `Symbol` of rank 3 and spatial dimension ``dim``.
92
93 :param dim: spatial dimension or an object that has the ``getDim`` method
94 defining the spatial dimension
95 :type dim: ``int`` or any object with a ``getDim`` method
96 :return: a `Symbol` of shape (``dim``,``dim``,``dim``)
97 :rtype: `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 `Symbol` of rank 4 and spatial dimension ``dim``.
108
109 :param dim: spatial dimension or an object that has the ``getDim`` method
110 defining the spatial dimension
111 :type dim: ``int`` or any object with a ``getDim`` method
112 :return: a `Symbol` of shape (``dim``,``dim``,``dim``,``dim``)
113 :rtype: `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