Skip to content

Commit 5b794d2

Browse files
Version 3
1 parent d857e54 commit 5b794d2

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int v = (int) Julia.Eval("2 * 2");
2525
Julia.Exit(0); //Even if your program terminates after you should call this. It runs the finalizers and stuff
2626
```
2727

28-
Struct Handling:
28+
Structs:
2929
```csharp
3030

3131
#You have two choices, allocate a struct or create a struct.
@@ -35,7 +35,7 @@ Struct Handling:
3535
var myCreatedStuct = JLType.JLRef.Create(3); //Will call constructor
3636
```
3737

38-
Function Handling:
38+
Functions:
3939
```csharp
4040
JLFun fun = Julia.Eval("t(x::Int) = Int32(x * 2)");
4141
JLSvec ParameterTypes = fun.ParameterTypes;
@@ -45,7 +45,7 @@ Function Handling:
4545
JLVal resultWillBe4 = fun.Invoke(2);
4646
```
4747

48-
Value Handling:
48+
Values:
4949
```csharp
5050
//Auto alloc to Julia
5151
var val = new JLVal(3);
@@ -57,17 +57,23 @@ Value Handling:
5757
object newVal2 = val.Value;
5858
```
5959

60-
Array Handling:
60+
Arrays:
6161
```csharp
6262
JLArray arr = Julia.Eval("[2, 3, 4]")
6363

6464
//Unpack to .net
65-
object[] o = arr.LinearNetUnPack();
65+
object[] o = arr.UnboxArray();
6666

67-
//Make own array
68-
var newArray = long[arr.Length];
69-
for(int i = 1; i <= arr.Length; ++i)
70-
newArray[i - 1] = (long) arr[i];
67+
var a = new int[]{2, 3, 4};
68+
69+
//Copy to a Julia Array. Dont use this method if you know an object is an array though. There are faster methods!
70+
var v = new JLVal(a);
71+
72+
//Fast Array Copy From .NET. This will deal with direct memory transfer rather then boxing/unboxing for unmanaged types
73+
var v2 = JLArray.CreateArray(a);
74+
75+
//Fast Array Copy From Julia. This will deal with direct memory transfer rather then boxing/unboxing for unmanaged types
76+
int[] v2 = v2.UnboxArray<int>();
7177

7278
JLType elementType = arr.ElType;
7379
```

0 commit comments

Comments
 (0)