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

Resolve diagcat issue #2284

Open
jgillis opened this issue Jun 15, 2018 · 4 comments
Open

Resolve diagcat issue #2284

jgillis opened this issue Jun 15, 2018 · 4 comments
Assignees
Milestone

Comments

@jgillis
Copy link
Member

jgillis commented Jun 15, 2018

https://groups.google.com/forum/#!topic/casadi-users/56qNv_JaLHw

f427f24

@jgillis jgillis added this to the Version 3.5 milestone Jun 15, 2018
@jgillis jgillis self-assigned this Jun 15, 2018
@jaeandersson
Copy link
Member

The implementation should have used recursive calls. It's more maintainable.

@jaeandersson
Copy link
Member

Something like:

  MX MX::diagcat(const vector<MX>& x) {
    // Quick return if empty or single element
    if (x.empty()) return MX();
    if (x.size()==1) return x.front();
    // Call recursively if any 0-by-0 matrices
    if (has_empty(x, true)) return diagcat(trim_empty(x, true));
    // Create diagcat node
    return x.front()->get_diagcat(x);
 }

@jgillis
Copy link
Member Author

jgillis commented Aug 7, 2018

More from forum:

>>> horzcat(SX([]), SX([1,2]))
SX(
[[00, 1],
 [00, 2]])
>>> horzcat(MX([]), MX([1,2]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/marco/.local/lib/python2.7/site-packages/casadi/casadi.py", line 467, in horzcat
    def horzcat(*args): return _horzcat(args)
  File "/home/marco/.local/lib/python2.7/site-packages/casadi/casadi.py", line 18924, in _horzcat
    return _casadi._horzcat(*args)
RuntimeError: .../casadi/core/mx.cpp:932: Assertion "ne[i].size1()==ne[0].size1()" failed:
horzcat dimension mismatch  x[1]:2x1 and x[0]: 0x1.
>>> horzcat(DM([]), DM([1,2]))
DM(
[[00, 1],
 [00, 2]])
>>> horzcat(DM([]), IM([1,2]))
IM(
[[00, 1],
``

@jgillis jgillis modified the milestones: Version 3.5, Version 3.7 Mar 30, 2023
@jgillis
Copy link
Member Author

jgillis commented Mar 30, 2023

Still an issue for 3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants