Skip to content
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

Concatenating an arbitrary number of matrices horizontally with mortar #302

Closed
EssamWisam opened this issue Jul 29, 2023 · 1 comment
Closed

Comments

@EssamWisam
Copy link

EssamWisam commented Jul 29, 2023

I know I can do

a = randn(3, 3)
mortar((a, a, a))

However, in my case, a is not defined in the code, it's arbitrarily generated from a function that I will call many times. For instance, consider

f(a) = a

I tried both of these and neither seems to work

mortar(([f(a) for i in 1:3]...))
mortar(tuple([f(a) for i in 1:3]))
@jishnub
Copy link
Member

jishnub commented Aug 25, 2023

You're not constructing the Tuple correctly. In any case, your test function should return a matrix, and not an integer.

This should work:

julia> f(a) = fill(a,2,2)
f (generic function with 1 method)

julia> Tuple([f(i) for i in 1:3])
([1 1; 1 1], [2 2; 2 2], [3 3; 3 3])

julia> mortar(Tuple([f(i) for i in 1:4]))
1×4-blocked 2×8 BlockMatrix{Int64}:
 1  12  23  34  4
 1  12  23  34  4

@jishnub jishnub closed this as completed Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants