-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
|
||
from .function_base import * | ||
from .polynomial import * | ||
from .type_check import * | ||
from .type_check import * | ||
from .block import * |
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,17 @@ | ||
from ulab.numpy import zeros | ||
|
||
def block(S): | ||
w = sum([len(m[0]) for m in S[0]]) | ||
h = sum([len(row[0]) for row in S]) | ||
M = zeros((h, w)) | ||
i = 0 | ||
j = 0 | ||
for row in S: | ||
di = len(row[0]) | ||
for matrix in row: | ||
dj = len(matrix[0]) | ||
M[i:i + di, j:j + dj] = matrix | ||
j += dj | ||
i += di | ||
j = 0 | ||
return M |
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 @@ | ||
from ulab.numpy import array, zeros, eye, ones | ||
from snippets import numpy | ||
|
||
a = array([[1, 1]]) | ||
b = array([[2]]) | ||
c = array( | ||
[[3, 3], | ||
[3, 3], | ||
[3, 3]]) | ||
d = array( | ||
[[4], | ||
[4], | ||
[4]]) | ||
print(numpy.block([[a, b], [c, d]])) | ||
a = zeros((2, 3)) | ||
b = eye(2) * 2 | ||
c = eye(3) * 5 | ||
d = ones((3, 2)) | ||
print(numpy.block([[a, b], [c, d]])) |
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,9 @@ | ||
array([[1, 1, 2], | ||
[3, 3, 4], | ||
[3, 3, 4], | ||
[3, 3, 4]]) | ||
array([[0, 0, 0, 2, 0], | ||
[0, 0, 0, 0, 2], | ||
[5, 0, 0, 1, 1], | ||
[0, 5, 0, 1, 1], | ||
[0, 0, 5, 1, 1]]) |