-
Notifications
You must be signed in to change notification settings - Fork 30
Geometric Algebra Types #4009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Geometric Algebra Types #4009
Changes from 7 commits
02737ae
aadf409
b8c5bbd
4ecf77d
c5fd09b
7dcb188
5b3c919
aca77d1
d55288e
905a96b
ebebbf3
f32335a
2b24b9b
1af0625
3d6d52a
fb06419
960c0a5
f921ccf
87675e8
ded720e
f323dbc
b4b6cb5
e58564a
f16d784
8887c09
5274725
3025324
8d4747d
38aba8b
5e3a82e
ba0f0da
47207ae
9bce503
01d5aee
b48ac7e
30fe9ea
445440d
5ab549d
599361b
7eaf629
8c25b38
f03bf6c
8be1c15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "GitHub Codespaces (Haskell)", | ||
| "image": "davidgontrum/haskellcodespaces", | ||
| "settings": { | ||
| "terminal.integrated.shell.linux": "/bin/bash", | ||
| }, | ||
| "remoteUser": "codespace", | ||
| "overrideCommand": false, | ||
| "workspaceMount": "source=${localWorkspaceFolder},target=/home/codespace/workspace,type=bind,consistency=cached", | ||
| "workspaceFolder": "/home/codespace/workspace", | ||
| "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind" ], | ||
| "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], | ||
|
|
||
| "extensions": [ | ||
| "haskell.haskell", | ||
| "k--kato.intellij-idea-keybindings", | ||
| "GitHub.vscode-pull-request-github", | ||
| "MS-vsliveshare.vsliveshare" | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ module Data.Drasil.ExternalLibraries.ODELibraries ( | |
| ) where | ||
|
|
||
| import Language.Drasil (HasSymbol(symbol), HasUID(uid), MayHaveUnit(getUnit), | ||
| QuantityDict, HasSpace(typ), Space (Actor, Natural, Real, Void, Boolean, String, Array, Vect), implVar, | ||
| QuantityDict, HasSpace(typ), Space (Actor, Natural, Real, Void, Boolean, String, Array, ClifS), implVar, | ||
| implVarUID, implVarUID', qw, compoundPhrase, nounPhrase, nounPhraseSP, label, | ||
| sub, Idea(getA), NamedIdea(term), Stage(..), (+++)) | ||
| import Language.Drasil.Display (Symbol(Label, Concat)) | ||
|
|
@@ -443,15 +443,15 @@ odeint = externalLib [ | |
| customObjArg [] "Class representing an ODE system" ode odeCtor | ||
| (customClass [constructorInfo odeCtor [] [], | ||
| methodInfoNoReturn odeOp "function representation of ODE system" | ||
| [unnamedParam (Vect Real), unnamedParam (Vect Real), lockedParam t] | ||
| [unnamedParam undefined, unnamedParam undefined, lockedParam t] -- TODO: what do we put here? We need specific dimensions now. | ||
|
||
| [assignArrayIndex]]), | ||
| -- Need to declare variable holding initial value because odeint will update this variable at each step | ||
| preDefinedArg odeintCurrVals, | ||
| inlineArg Real, inlineArg Real, inlineArg Real, | ||
| customObjArg [] | ||
| "Class for populating a list during an ODE solution process" | ||
| pop popCtor (customClass [ | ||
| constructorInfo popCtor [unnamedParam (Vect Real)] [], | ||
| constructorInfo popCtor [unnamedParam undefined] [], -- TODO: Same as above TODO | ||
| methodInfoNoReturn popOp | ||
| "appends solution point for current ODE solution step" | ||
| [lockedParam y, lockedParam t] [appendCurrSol (sy y)]])]] | ||
|
|
@@ -496,7 +496,7 @@ odeintCurrVals, rk, stepper, pop :: CodeVarChunk | |
| odeintCurrVals = quantvar $ implVar "currVals_odeint" (nounPhrase | ||
| "vector holding ODE solution values for the current step" | ||
| "vectors holding ODE solution values for the current step") | ||
| (Vect Real) (label "currVals") | ||
| undefined (label "currVals") -- TODO: Same as above, what do we fill in here? | ||
| rk = quantvar $ implVar "rk_odeint" (nounPhrase | ||
| "stepper for solving ODE system using Runge-Kutta-Dopri5 method" | ||
| "steppers for solving ODE system using Runge-Kutta-Dopri5 method") | ||
|
|
@@ -555,7 +555,7 @@ t = quantvar $ implVar "t_ode" (nounPhrase | |
| y = quantvar $ implVar "y_ode" (nounPhrase | ||
| "current dependent variable value in ODE solution" | ||
| "current dependent variable value in ODE solution") | ||
| (Vect Real) (label "y") | ||
| undefined (label "y") -- TODO: Same as above - what dimension do we use here? | ||
|
|
||
| -- | ODE object constructor. | ||
| odeCtor :: CodeFuncChunk | ||
|
|
@@ -599,8 +599,8 @@ modifiedODESyst sufx info = map replaceDepVar (odeSyst info) | |
| replaceDepVar (Matrix es) = Matrix $ map (map replaceDepVar) es | ||
| replaceDepVar (UnaryOp u e) = UnaryOp u $ replaceDepVar e | ||
| replaceDepVar (UnaryOpB u e) = UnaryOpB u $ replaceDepVar e | ||
| replaceDepVar (UnaryOpVV u e) = UnaryOpVV u $ replaceDepVar e | ||
| replaceDepVar (UnaryOpVN u e) = UnaryOpVN u $ replaceDepVar e | ||
| replaceDepVar (UnaryOpCC u e) = UnaryOpCC u $ replaceDepVar e | ||
| replaceDepVar (UnaryOpCN u e) = UnaryOpCN u $ replaceDepVar e | ||
| replaceDepVar (ArithBinaryOp b e1 e2) = ArithBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (BoolBinaryOp b e1 e2) = BoolBinaryOp b | ||
|
|
@@ -611,9 +611,9 @@ modifiedODESyst sufx info = map replaceDepVar (odeSyst info) | |
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (OrdBinaryOp b e1 e2) = OrdBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (VVNBinaryOp b e1 e2) = VVNBinaryOp b | ||
| replaceDepVar (CCNBinaryOp b e1 e2) = CCNBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (VVVBinaryOp b e1 e2) = VVVBinaryOp b | ||
| replaceDepVar (CCCBinaryOp b e1 e2) = CCCBinaryOp b | ||
| (replaceDepVar e1) (replaceDepVar e2) | ||
| replaceDepVar (Operator ao dd e) = Operator ao dd $ replaceDepVar e | ||
| replaceDepVar e = e | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ spaceToCodeType S.Rational = [Double, Float] | |
| spaceToCodeType S.Boolean = [Boolean] | ||
| spaceToCodeType S.Char = [Char] | ||
| spaceToCodeType S.String = [String] | ||
| spaceToCodeType (S.Vect s) = map List (spaceToCodeType s) | ||
| spaceToCodeType (S.ClifS _ _ s) = map List (spaceToCodeType s) | ||
| spaceToCodeType (S.Matrix _ _ s) = map (List . List) (spaceToCodeType s) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you're choosing not to replace
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops - I should have included that as another question. I didn't because I wasn't quite sure what kind of clif it should be represented as. Do you have thoughts? Would an m-by-n matrix be represented as something like an n-grade clif in an m-dimensional space? Dr. Smith and I did some research and there's not much about using clifs to represent matrices. The geometric algebra people have this attitude of "we don't need matrices" so they seem not to even think about them.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://math.stackexchange.com/questions/850869/linear-algebra-without-matrices is one place to start reading. It points to the nice book "Linear Algebra Done Right" which is really quite a gem. [In a sense, chapter 1 of https://arkadiusz-jadczyk.eu/docs/clifford.pdf says that concrete Clifford Algebras are equivalent to some spaces of matrices...] However, we will still want to be able to enter 'concrete' matrices (in a basis). The book "Guide to Geometric Algebra in Practice " is available for download from McMaster's library - I think that one would help most.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JacquesCarette these look to be good resources. @CSchank can you please add links to these resources to your slide show on Clifford algebra. I worry that if we the links only appear here, we won't be able to find them in the future if we go looking. 😄
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| spaceToCodeType (S.Set s) = map List (spaceToCodeType s) | ||
| spaceToCodeType (S.Array s) = map Array (spaceToCodeType s) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| import Language.Drasil.Code.DataDesc (DataDesc'(..), Data'(..), DataItem'(..), | ||
| Delimiter, dataDesc, junk, list, singleton') | ||
| import Language.Drasil.Chunk.Code (CodeVarChunk) | ||
| import Language.Drasil.Expr.Development (Expr(Matrix)) | ||
| import Language.Drasil.Expr.Development (Expr(Matrix, Clif)) -- TODO: remove Matrix entirely | ||
JacquesCarette marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
JacquesCarette marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import Control.Lens ((^.)) | ||
| import Data.List (intersperse, isPrefixOf, transpose) | ||
|
|
@@ -66,7 +66,7 @@ | |
| sampleInputDD :: [CodeVarChunk] -> DataDesc' | ||
| sampleInputDD ds = dataDesc (junk : intersperse junk (map toData ds)) "\n" | ||
| where toData d = toData' (d ^. typ) d | ||
| toData' t@(Vect _) d = list d | ||
| toData' t@(ClifS _ _ _) d = list d | ||
|
Check warning on line 69 in code/drasil-code/lib/Language/Drasil/Code/Imperative/ReadInput.hs
|
||
| (take (getDimension t) ([", ", "; "] ++ iterate (':':) ":")) | ||
| toData' _ d = singleton' d | ||
|
|
||
|
|
@@ -83,7 +83,7 @@ | |
|
|
||
| -- | Gets the dimension of a 'Space'. | ||
| getDimension :: Space -> Int | ||
| getDimension (Vect t) = 1 + getDimension t | ||
| getDimension (ClifS _ _ s) = 1 + getDimension s -- TODO: Does this make sense? Maybe we're overloading the term "dimension" now. | ||
|
||
| getDimension _ = 0 | ||
|
|
||
| -- | Splits a string at the first (and only the first) occurrence of a delimiter. | ||
|
|
@@ -98,12 +98,12 @@ | |
| dropDelim [] s = s | ||
| dropDelim _ [] = error "impossible" | ||
|
|
||
| -- | Converts a list of 'String's to a Matrix 'Expr' of a given 'Space'. | ||
| -- | Converts a list of 'String's to a Clif 'Expr' of a given 'Space'. | ||
| strListAsExpr :: Space -> [String] -> Expr | ||
| strListAsExpr (Vect t) ss = Matrix [map (strAsExpr t) ss] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you shouldn't do |
||
| strListAsExpr (ClifS gr d s) ss = undefined -- TODO: fill this in | ||
| strListAsExpr _ _ = error "strListsAsExpr called on non-vector space" | ||
|
|
||
| -- | Converts a 2D list of 'String's to a Matrix 'Expr' of a given 'Space'. | ||
| -- | Converts a 2D list of 'String's to a Clif 'Expr' of a given 'Space'. | ||
| strList2DAsExpr :: Space -> [[String]] -> Expr | ||
| strList2DAsExpr (Vect (Vect t)) sss = Matrix $ map (map (strAsExpr t)) sss | ||
| strList2DAsExpr (ClifS gr0 d0 (ClifS gr1 d1 s)) sss = undefined -- TODO: fill this in | ||
|
||
| strList2DAsExpr _ _ = error "strLists2DAsExprs called on non-2D-vector space" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,8 @@ acceleration, angularAccel, angularDisplacement, angularVelocity, chgInVelocity, | |
| yVel, momentum, moment, moment2D, fOfGravity, positionVec, tension, angularFrequency, | ||
| period, frequency, chgMomentum :: UnitalChunk | ||
|
|
||
| acceleration = uc CP.acceleration (Concat [vec lA, label "(", lT, label ")"]) (Vect Real) accelU | ||
| -- TODO: what should the type here be? | ||
| acceleration = uc CP.acceleration (Concat [vec lA, label "(", lT, label ")"]) undefined accelU | ||
|
||
| angularAccel = uc CP.angAccel lAlpha Real angAccelU | ||
| angularDisplacement = uc CP.angDisp lTheta Real radian | ||
| angularFrequency = uc CP.angFreq cOmega Real second | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
|
|
||
| module Drasil.GlassBR.ModuleDefs (allMods, implVars, interpY, interpZ) where | ||
|
|
||
| import Language.Drasil (QuantityDict, Space(..), implVar, nounPhraseSP, | ||
| import Language.Drasil (QuantityDict, Space(..), vect3D, implVar, nounPhraseSP, | ||
| label, sub, HasSymbol(..), HasUID, Symbol) | ||
| import Language.Drasil.Display (Symbol(..)) | ||
| import Language.Drasil.ShortHands | ||
|
|
@@ -64,25 +64,25 @@ y = var "y" "y-coordinate to interpolate at" lY Real | |
| z = var "z" "z-coordinate to interpolate at" lZ Real | ||
|
|
||
| zVector = var "zVector" "list of z values" | ||
| (sub lZ (label "vector")) (Vect Real) | ||
| (sub lZ (label "vector")) (vect3D Real) | ||
| yMatrix = var "yMatrix" "lists of y values at different z values" | ||
| (sub lY (label "matrix")) (Vect $ Vect Real) | ||
| (sub lY (label "matrix")) (vect3D $ vect3D Real) | ||
| xMatrix = var "xMatrix" "lists of x values at different z values" | ||
| (sub lX (label "matrix")) (Vect $ Vect Real) | ||
| (sub lX (label "matrix")) (vect3D $ vect3D Real) | ||
| arr = var "arr" "array in which value should be found" | ||
| (label "arr") (Vect Real) --FIXME: temporary variable for findCT? | ||
| (label "arr") (vect3D Real) --FIXME: temporary variable for findCT? | ||
| x_z_1 = var "x_z_1" "list of x values at a specific z value" | ||
| (sub lX (sub lZ one)) (Vect Real) | ||
| (sub lX (sub lZ one)) (vect3D Real) | ||
| y_z_1 = var "y_z_1" "list of y values at a specific z value" | ||
| (sub lY (sub lZ one)) (Vect Real) | ||
| (sub lY (sub lZ one)) (vect3D Real) | ||
| x_z_2 = var "x_z_2" "list of x values at a specific z value" | ||
| (sub lX (sub lZ two)) (Vect Real) | ||
| (sub lX (sub lZ two)) (vect3D Real) | ||
| y_z_2 = var "y_z_2" "list of y values at a specific z value" | ||
| (sub lY (sub lZ two)) (Vect Real) | ||
| (sub lY (sub lZ two)) (vect3D Real) | ||
| mat = var "mat" "matrix from which column will be extracted" | ||
| (label "mat") (Vect $ Vect Real) | ||
| (label "mat") (vect3D $ vect3D Real) | ||
| col = var "col" "extracted column" | ||
| (label "col") (Vect Real) | ||
| (label "col") (vect3D Real) | ||
| filename = var "filename" "name of file with x y and z data" | ||
| (label "filename") String | ||
|
|
||
|
|
@@ -152,7 +152,7 @@ findCT = funcDef "find" | |
|
|
||
| extractColumnCT :: Func | ||
| extractColumnCT = funcDef "extractColumn" "Extracts a column from a 2D matrix" | ||
| [mat, j] (Vect Real) (Just "column of the given matrix at the given index") | ||
| [mat, j] (vect3D Real) (Just "column of the given matrix at the given index") -- TODO: is this correct? | ||
|
||
| [ | ||
| fDecDef col (matrix [[]]), | ||
| -- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -415,7 +415,7 @@ outputs = [tempW, tempPCM, watE, pcmE] | |
| tempW = cuc' "tempW" | ||
| (nounPhraseSP "temperature of the water") | ||
| "the average kinetic energy of the particles within the water" | ||
| (sub (eqSymb temp) lWater) centigrade (Vect Real) | ||
| (sub (eqSymb temp) lWater) centigrade (vect undefined Real) -- TODO: dimension of vector? | ||
|
||
| [physRange $ Bounded (Inc, sy tempInit) (Inc, sy tempC)] (exactDbl 0) | ||
|
|
||
| -- Constraint 19 | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to add this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, I should have explained. This was so I could develop the project on GitHub Codespaces (instead of using more disk space on my laptop). It's up to you if you want to merge it in or not, I can remove it from any future mergeable PRs. It's actually not foolproof because it doesn't install Stack by default yet. If you're interested I'll get it fully working, if not, I'll leave it as-is/remove it before we merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On that topic, I'll want the opinion of @balacij .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not against this, but I'm hesitant to say we should merge until (at least):
Does HLS work with this? I would imagine that GitHub Codespaces has fairly limited resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we should definitely not merge this in via this particular PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@balacij HLS works on Codespaces just fine, the smallest one has 2 vCores, 8gb of RAM and 32gb of storage. But I agree we shouldn't merge this yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, there is a way to get "unlimited" (for practical purposes) Codespaces for free for education settings. It is nice for helping people get started for sure.