Skip to content

Add do_vl/do_vr opt-out flags to EigenSystem#795

Open
yungyuc wants to merge 1 commit into
solvcon:masterfrom
yungyuc:feat/left-right
Open

Add do_vl/do_vr opt-out flags to EigenSystem#795
yungyuc wants to merge 1 commit into
solvcon:masterfrom
yungyuc:feat/left-right

Conversation

@yungyuc
Copy link
Copy Markdown
Member

@yungyuc yungyuc commented May 20, 2026

Allow to construct the class EigenSystem with do_vl=false and/or do_vr=false to skip the corresponding eigenvector computation.

With the options to be off, the corresponding matrix stays empty. Calling the getters vl() / vr() throw when the matrix was not computed unless called with suppress_exception=true, which returns the empty placeholder.

Python keeps vl / vr as read-only properties and adds get_vl() / get_vr() helpers exposing the flag.

Related to issue #791.

@yungyuc yungyuc self-assigned this May 20, 2026
@yungyuc yungyuc added the array Multi-dimensional array implementation label May 20, 2026
@yungyuc yungyuc moved this from Todo to In Progress in tensor operations May 20, 2026
.def(
"get_vl",
&wrapped_type::vl,
py::arg("suppress_exception") = false,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New getters to allow throwing an exception and suppress it.

array_type const & wi() const { return m_wi; }
array_type const & vl() const { return m_vl; }
array_type const & vr() const { return m_vr; }
array_type const & vl(bool suppress_exception = false) const;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add suppression argument.

array_type const & vr() const { return m_vr; }
array_type const & vl(bool suppress_exception = false) const;
array_type const & vr(bool suppress_exception = false) const;
bool do_vl() const { return m_do_vl; }
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add getter for do_vl/vr()

*/
char const jobvl = 'V';
char const jobvr = 'V';
char const jobvl = m_do_vl ? 'V' : 'N';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the calculation selector.

*/
inline EigenSystem::array_type const & EigenSystem::vl(bool suppress_exception) const
{
if (!m_do_vl && !suppress_exception)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw exception if vl is not requested.

*/
inline EigenSystem::array_type const & EigenSystem::vr(bool suppress_exception) const
{
if (!m_do_vr && !suppress_exception)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw exception if vr is not requested.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why there is a "suppress_exception" design? Why not always throwing?

Comment thread tests/test_linalg.py
del A
np.testing.assert_array_equal(solver.matrix.ndarray, A_np)

def test_default_constructor_flags_both_true(self):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test functions for the optional vl / vr calculation.

Allow to construct the class `EigenSystem` with `do_vl=false` and/or
`do_vr=false` to skip the corresponding eigenvector computation.

With the options to be off, the corresponding matrix stays empty.  Calling the
getters `vl()` / `vr()` throw when the matrix was not computed unless called
with `suppress_exception=true`, which returns the empty placeholder.

Python keeps `vl`/`vr` as read-only properties and adds `get_vl()` / `get_vr()`
helpers exposing the flag.

Related to issue solvcon#791.
@yungyuc yungyuc force-pushed the feat/left-right branch from 5ff7dad to de283af Compare May 20, 2026 14:51
@yungyuc yungyuc marked this pull request as ready for review May 20, 2026 15:27
@yungyuc yungyuc requested review from KHLee529 and tigercosmos May 20, 2026 15:27
Copy link
Copy Markdown
Collaborator

@tigercosmos tigercosmos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Raised one question.

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

Labels

array Multi-dimensional array implementation

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants