-
Notifications
You must be signed in to change notification settings - Fork 548
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
Simplified form of 2d vector #385
Comments
I think
is better. we could format the code to multiline when there is ';' by the format tool. so the code will look like below:
put the ']' in new line, so it will be easy for user to add new row in vector. |
@damonchen a := [a11, a12, ..., a1N; a21, a22, ..., a2N; ...; aM1, aM2, ..., aMN] is equal to a := [a11, a12, ..., a1N
a21, a22, ..., a2N
...
aM1, aM2, ..., aMN] Of course, if we allow empty line in 2d vector, it can be a := [
a11, a12, ..., a1N
a21, a22, ..., a2N
...
aM1, aM2, ..., aMN
] |
X := [A..., B..., c1, c2, ..., cN]
Y := [
A...
B...
c1, c2, ..., cN
]
Z := [
A1..., A2..., a1, a2, ..., aN
B...
C1..., C2...
d1, d2, ..., dM
] is equivalent to: X := concat(A, B, [c1, c2, ..., cN])
Y := vconcat(A, B, [c1, c2, ..., cN])
Z := vconcat(
concat(A1, A2, [a1, a2, ..., aN]),
B,
concat(C1, C2),
[d1, d2, ..., dM]) prototype: type matrix[T number] struct {
Data []T
Row, Col int
}
func matrix[T].icast(v []T) matrix[T] { // T.icast means `implicit cast of type T`
return matrix[T]{v, 1, len(v)}
}
func concat[T string](args ...T) T
func concat[T number](args ...[]T) []T
func concat(T number](args ...matrix[T]) matrix[T]
func vconcat[T number](args ...matrix[T]) matrix[T] For more details about |
can be:
or:
The text was updated successfully, but these errors were encountered: