-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from Morpho-lang/dev
v0.6.1 updated version
- Loading branch information
Showing
12 changed files
with
205 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,19 @@ | ||
// Ensure a block contructor produces the correct matrix dimensions | ||
|
||
var a = Sparse() | ||
|
||
for (i in 0..4:2) { | ||
a[i,i]=1 | ||
a[i+1,i]=2 | ||
a[i+3,i]=3 | ||
} | ||
|
||
print Sparse([[a.column(0),a.column(1)]]) | ||
// expect: [ 1 0 ] | ||
// expect: [ 2 0 ] | ||
// expect: [ 0 0 ] | ||
// expect: [ 3 0 ] | ||
// expect: [ 0 0 ] | ||
// expect: [ 0 0 ] | ||
// expect: [ 0 0 ] | ||
// expect: [ 0 0 ] |
This file contains 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,40 @@ | ||
// Sparse matrices | ||
|
||
var a = Sparse() | ||
|
||
for (i in 0..4:2) { | ||
a[i,i]=1 | ||
a[i+1,i]=2 | ||
a[i+3,i]=3 | ||
} | ||
|
||
print a.column(0) | ||
// expect: [ 1 ] | ||
// expect: [ 2 ] | ||
// expect: [ 0 ] | ||
// expect: [ 3 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
|
||
print a.column(1) | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
|
||
print a.column(4) | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 0 ] | ||
// expect: [ 1 ] | ||
// expect: [ 2 ] | ||
// expect: [ 0 ] | ||
// expect: [ 3 ] | ||
|
This file contains 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 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,24 @@ | ||
// | ||
|
||
var N = 3 | ||
|
||
var A = Sparse(2*N,N) | ||
for (i in 0...N) { | ||
A[i,i]=1 | ||
A[i+N,i]=1 | ||
} | ||
|
||
var b = Matrix(List(1..N)) | ||
|
||
print A.dimensions() // expect: [ 6, 3 ] | ||
print b.dimensions() // expect: [ 3, 1 ] | ||
|
||
print (A*b).dimensions() // expect: [ 6, 1 ] | ||
|
||
print A*b | ||
// expect: [ 1 ] | ||
// expect: [ 2 ] | ||
// expect: [ 3 ] | ||
// expect: [ 1 ] | ||
// expect: [ 2 ] | ||
// expect: [ 3 ] |
14 changes: 14 additions & 0 deletions
14
test/types/multiple_dispatch/apply_invocation_multiple_dispatch.morpho
This file contains 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,14 @@ | ||
class A { | ||
a() { return 0 } | ||
a(x) { return 1 } | ||
a(x, y) { return 2 } | ||
a(x, y, z) { return 3 } | ||
} | ||
|
||
var a = A() | ||
var b = a.a | ||
|
||
print apply(b, []) // expect: 0 | ||
print apply(b, [1]) // expect: 1 | ||
print apply(b, [1,1]) // expect: 2 | ||
print apply(b, [1,1,1]) // expect: 3 |
14 changes: 14 additions & 0 deletions
14
test/types/multiple_dispatch/invocation_multiple_dispatch.morpho
This file contains 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,14 @@ | ||
class A { | ||
a() { return 0 } | ||
a(x) { return 1 } | ||
a(x, y) { return 2 } | ||
a(x, y, z) { return 3 } | ||
} | ||
|
||
var a = A() | ||
var b = a.a | ||
|
||
print b() // expect: 0 | ||
print b(1) // expect: 1 | ||
print b(1,1) // expect: 2 | ||
print b(1,1,1) // expect: 3 |