@@ -55,6 +55,9 @@ class _VectorZero(VectorExpr):
55
55
except for the constant `ZERO` since under the `definition of vector spaces
56
56
<https://en.wikipedia.org/wiki/Vector_space#Definition_and_basic_properties>` there can only
57
57
be one zero.
58
+
59
+ Note that the zero vector can be considered having arbitrary (physical) dimension as it can be
60
+ added to all vectors.
58
61
"""
59
62
60
63
def _sympystr (self , _p : Printer ) -> str :
@@ -101,14 +104,7 @@ def __new__(
101
104
if norm == 0 :
102
105
return ZERO
103
106
104
- obj = VectorExpr .__new__ (cls )
105
- obj .__init__ (
106
- display_symbol = display_symbol ,
107
- dimension = dimension ,
108
- norm = norm ,
109
- display_latex = display_latex ,
110
- )
111
- return obj
107
+ return VectorExpr .__new__ (cls )
112
108
113
109
def __init__ (
114
110
self ,
@@ -172,7 +168,7 @@ class VectorNorm(Expr): # type: ignore[misc]
172
168
def argument (self ) -> VectorExpr :
173
169
return self .args [0 ] # type: ignore[no-any-return]
174
170
175
- # NOTE: Add __new__ that would dispatch the code execusing depending on the value of `vector`
171
+ # NOTE: Add __new__ that would dispatch the code execusion depending on the value of `vector`
176
172
# For now, this is handled by the function `norm` below.
177
173
def __init__ (self , vector : VectorExpr ) -> None :
178
174
self ._args = (vector ,)
@@ -229,6 +225,8 @@ class VectorScale(VectorExpr):
229
225
230
226
3. For all scalars `k` and vectors `a`, `k * a = 0` implies `k = 0` or `a = 0`.
231
227
228
+ 4. For all vectors `a`, `(-1) * a = -a` where `-a` is the additive inverse of `a`.
229
+
232
230
**Links:**
233
231
234
232
1. `Wikipedia <https://en.wikipedia.org/wiki/Vector_space#Definition_and_basic_properties>`__.
@@ -290,34 +288,24 @@ def _sympystr(self, p: Printer) -> str:
290
288
return f"{ p .doprint (vector )} *{ p .doprint (value )} "
291
289
292
290
293
- class Scale (Expr ): # type: ignore[misc]
294
- """
295
- Wrapper class intended to allow the scale to come first in the case of scalar multiplication,
296
- since using an unwrapped `Expr` in the LHS of the multiplication would yield a `TypeError`.
291
+ class VectorAdd (VectorExpr ):
297
292
"""
293
+ Class representing the notion of vector *addition* as a property of vectors.
298
294
299
- def __init__ (self , scale : Any ) -> None :
300
- self ._args = (scale ,)
295
+ Note that the addends must have the same (physical) dimension to be added together.
301
296
302
- def __mul__ (self , other : Any ) -> VectorScale :
303
- if isinstance (other , VectorExpr ):
304
- return VectorScale (other , self .args [0 ]).doit ()
297
+ This operation has the following properties:
305
298
306
- raise TypeError (
307
- f"Scale can only be multiplied with a VectorExpr, got { type (other ).__name__ } ." )
299
+ 1. **Associativity**: for all vectors `a, b, c`, `a + (b + c) = (a + b) + c`.
308
300
309
- def _eval_nseries (self , x : Any , n : Any , logx : Any , cdir : Any ) -> Any :
310
- pass
301
+ 2. **Commutativity**: for all vectors `a, b`, `a + b = b + a`.
311
302
303
+ 3. Existence of **identity vector** `0`: for all vectors `a`, `a + 0 = a`.
312
304
313
- class VectorAdd (VectorExpr ):
314
- """
315
- Class representing the notion of vector addition as a property of vectors.
305
+ 4. Existence of **inverse vector**: for all vectors `a`, there exists a vector `-a` s.t. `a + (-a) = 0`.
316
306
317
- Note that only
307
+ The *subtraction* of two vectors can be defined as such: for all vectors `a, b`, `a - b = a + (-b)`.
318
308
319
- This operation has the following properties:
320
-
321
309
**Links:**
322
310
323
311
1. `Wikipedia <https://en.wikipedia.org/wiki/Vector_space#Definition_and_basic_properties>`__.
@@ -409,7 +397,6 @@ def _sympystr(self, p: Printer) -> str:
409
397
410
398
__all__ = [
411
399
"ZERO" ,
412
- "Scale" ,
413
400
"VectorAdd" ,
414
401
"VectorExpr" ,
415
402
"VectorNorm" ,
0 commit comments