-
Notifications
You must be signed in to change notification settings - Fork 71
Added customized function (a little ugly) #101
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
Open
ingted
wants to merge
15
commits into
mathnet:master
Choose a base branch
from
ingted:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
99f5b75
customized_function
3822c76
customized_function
3fbc1f1
Update README.md
ingted e7e8ec7
Update README.md
ingted 5c21caf
Added vector/matrix support
2019f3a
Merge branch 'master' of github.com:ingted/mathnet-symbolics
baecc8b
Added vector/matrix debug project
2108a81
Update README.md
ingted 5ef25bd
matrix/vector multiplication
829c4da
Update README.md
ingted 92a8e5b
Update README.md
ingted 5617b8d
Update README.md
ingted 46d699a
Update README.md
ingted 784b37d
Update README.md
ingted b65b408
Update README.md
ingted File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Learn more about F# at http://fsharp.org | ||
|
||
open System | ||
open MathNet.Numerics.LinearAlgebra | ||
open MathNet.Symbolics | ||
let v = FloatingPoint.RealVector <| vector[1.0;2.0;3.0] | ||
|
||
let symbols2 = dict[ "a", v ] | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
let a0 = SymbolicExpression(Infix.parseOrThrow("a * 2")).Evaluate(symbols2) | ||
printfn "%A" a0.RealVectorValue | ||
let a1 = SymbolicExpression(Infix.parseOrThrow("a + 1")).Evaluate(symbols2) | ||
printfn "%A" a1.RealVectorValue | ||
let a2 = SymbolicExpression(Infix.parseOrThrow("mat_by_row(a, a)")).Evaluate(symbols2) | ||
printfn "%A" a2.RealMatrixValue | ||
0 // return an integer exit code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\src\Symbolics\Symbolics.fsproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace MathNet.Symbolics | ||
|
||
module Definition = | ||
|
||
type DefType = | ||
| DTExp of (Symbol list) * Expression | ||
| DTFunAction of (unit -> unit) | ||
| DTFunI1toI1 of (int -> int) | ||
| KeyWord | ||
|
||
let funDict = new System.Collections.Concurrent.ConcurrentDictionary<string, DefType>() | ||
|
||
let kwlist = [ "vec", true; "mat_by_row", true; "mat_by_col", true ] | ||
|
||
let keyWord = dict kwlist | ||
|
||
kwlist |> List.iter (fun (k, _) -> funDict.TryAdd(k, KeyWord) |> ignore) | ||
|
||
let defineSafe fnm exp = | ||
if keyWord.ContainsKey fnm then | ||
failwith "used function name" | ||
funDict.TryAdd (fnm, DTExp exp) | ||
|
||
let define fnm exp = | ||
if keyWord.ContainsKey fnm then | ||
failwith "used function name" | ||
funDict.AddOrUpdate( | ||
fnm | ||
, (fun nm -> DTExp exp) | ||
, (fun nm cur_exp -> DTExp exp) | ||
) | ||
|
||
let defAct fnm f = | ||
if keyWord.ContainsKey fnm then | ||
failwith "used function name" | ||
funDict.AddOrUpdate( | ||
fnm | ||
, (fun nm -> DTFunAction f) | ||
, (fun nm cur_exp -> DTFunAction f) | ||
) | ||
|
||
let def1ito1i fnm f = | ||
if keyWord.ContainsKey fnm then | ||
failwith "used function name" | ||
funDict.AddOrUpdate( | ||
fnm | ||
, (fun nm -> DTFunI1toI1 f) | ||
, (fun nm cur_exp -> DTFunI1toI1 f) | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what is it?
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 add small interesting functions to support Vector, Matrix, Tensor values.
The code would look like this:
If you are interested about it, I can add you...
(Why private? Because it is just like a toy and still a lot of works to do... )
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.
Output:
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.
Then, it should not be mentioned in ReadMe. Feel free to create issue though.