Skip to content

Commit

Permalink
Fix #511
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed May 10, 2024
1 parent 15069c5 commit 1a9a605
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 2 deletions.
145 changes: 143 additions & 2 deletions examples/ipython/issue-511.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
"data": {
"text/plain": [
"(1, e_0)"
"(e_0, e_0)"
]
},
"execution_count": 1,
Expand All @@ -28,9 +28,150 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "ea2d702a-dd04-4f5c-8794-1efefc8e7ee9",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{1}{8} \\mathbf{e}_{0}$"
],
"text/plain": [
"e_0/8"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(2*ex)**-3"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "09faf76e-f43c-4023-be91-3f2460de0456",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{1}{65536}$"
],
"text/plain": [
"1/65536"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(2*ex)**-16"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "91e20a05-ba7d-48cd-8916-d7460fb99e87",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2*e_0/29 + 3*e_1/29 + 4*e_2/29, 2*e_0/841 + 3*e_1/841 + 4*e_2/841)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"((2*ex + 3*ey + 4*ez).inv(), (2*ex + 3*ey + 4*ez)**-3)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "bdf6ce81-ab58-4e3b-aa72-6cd320e6062d",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{1}{841}$"
],
"text/plain": [
"1/841"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(2*ex + 3*ey + 4*ez).inv() * (2*ex + 3*ey + 4*ez)**-3"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "2a557448-ac80-4b1c-87a0-0d25d731953c",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 1$"
],
"text/plain": [
"1"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"((2*ex + 3*ey + 4*ez)**3) * (2*ex + 3*ey + 4*ez)**-3"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "fd88f171-7f74-4112-9123-e986d8d92d76",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 1$"
],
"text/plain": [
"1"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(2*ex + 3*ey + 4*ez)**-3 * ((2*ex + 3*ey + 4*ez)**3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "47ca185d-a790-4ba9-9c45-265572e6675d",
"metadata": {},
"outputs": [],
"source": []
}
Expand Down
3 changes: 3 additions & 0 deletions galgebra/mv.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,9 @@ def __ror__(self, A): # dot (|) product
def __pow__(self, n): # Integer power operator
if not isinstance(n, int):
raise ValueError('!!!!Multivector power can only be to integer power!!!!')

if n < 0:
return (self**(-n)).inv()

result = S.One
for x in range(n):
Expand Down

0 comments on commit 1a9a605

Please sign in to comment.