Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
HyperSphereStudio committed Jan 11, 2022
2 parents 297714c + c5aefe0 commit 6cf5c68
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,37 @@ Julia.NET is an API designed to go between .NET and the Julia Language. It utili

This is a very new library (created a couple days ago) so there is alot of things that can be added / fixed!

Example Usage:

Evaluation:
```csharp
Julia.Init();
int v = (int) Julia.Eval("2 * 2");
Julia.Exit(0);
```

Function Handling:
```csharp
Julia.Init();
Console.WriteLine(Julia.Eval("2.0 * 2.0").UnboxFloat64()); //Version 0.0.0
JLFun fun = Julia.Eval("t(x::Int) = Int32(x * 2)");
JLSvec ParameterTypes = fun.ParameterTypes;
JLType willbeInt64 = fun.ParameterTypes[1];
JLType willBeInt32 = fun.ReturnType;


//Version 0.0.1
Julia.Eval("t(x) = x * 2");
Julia.GetFunction(JLModule.Main, "t").Invoke(new JLVal(5)).Println();

//Version 0.0.2
JLFun fun = Julia.Eval("t(x) = x * 2");
fun.Invoke(5).Println();
int resultWillBe4 = (int) fun.Invoke(2);
object willReturnNetBoxed4 = fun.Invoke(2).Value;
```

//Version 0.0.3
JLFun fun = Julia.Eval("t(x) = x * 2");
Exception Handling:
```csharp
Julia.Init();
JLFun fun = Julia.Eval("t(x) = sqrt(x)");
fun.Invoke(5).Println(); //Exception Checking
fun.UnsafeInvoke(5).Println(); //No Exception Checking
//Version 0.0.4
JLFun fun = Julia.Eval("t(x) = sqrt(x)");
double result = (double) fun.Invoke(2);
object dotNetObject = fun.Invoke(3).Value;

Julia.Exit(0);
```



.NET Interface

The Julia.NET API also has a reverse calling API to call .NET from Julia. This also uses the C interface making it super fast (compared to message protocol based language interop systems. It depends on reflection which is the factor that slows it down compared to normal C# code).
Expand All @@ -52,3 +55,7 @@ o = sharpCon(6) #Create Instance
sharpField = SharpField(sharpType, "g") #Get Field
println(sharpField(o)) #Get Field Value
```



Library Written by Johnathan Bizzano

0 comments on commit 6cf5c68

Please sign in to comment.