Skip to content

upgrade degree-1 matrices to degree 2 when doing a comparison #1227

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Alex-Jordan
Copy link
Contributor

This is to address an issue I raised in the thread for #1215.

@pstaabp
Copy link
Member

pstaabp commented Apr 17, 2025

I think it would be a good idea to add these cases to the test suite.

@drgrice1
Copy link
Member

Could you provide a PG example of this? You gave an example mathematically in #1215 (comment), but I am having a hard time producing this in an actual PG problem. For example, I tried the following

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');

$vector = Vector(1, 0, 0);

$matrix = Matrix([ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]);

$result = $matrix * $vector;

$result2 = Matrix([ [ 1, 0, 0 ] ]);

BEGIN_PGML
[`[$vector]`] is a [@ ref($vector) @]

[`[$matrix]`] is a [@ ref($matrix) @]

[`[$result]`] is a [@ ref($result) @]

[`[$result2]`] is a [@ ref($result2) @]

[`[$matrix] \cdot [$vector] = [$result]`] is
[$matrix * $vector == $result ?  'true' : 'false']:

[`[$matrix] \cdot [$vector] = [$result2]`] is
[$matrix * $vector == $result2 ?  'true' : 'false']:
END_PGML

ENDDOCUMENT();

That problem renders the same for both the develop branch and this pull request, and the last comparison is an error in both cases. So I must be missing something as to what this is doing.

@Alex-Jordan
Copy link
Contributor Author

Here is a MWE that works in 2.19 and works on this PR's branch. But on develop, gives an error:

DOCUMENT();

loadMacros(qw(PGstandard.pl PGML.pl));

Context("Matrix");
$M = Matrix([1,2], [3,4]);
$s = Vector("<1,2>");
$Ms = $M*$s;
$b = Matrix(0,0)->transpose;

if ($Ms == $b || $Ms != $b) {
BEGIN_PGML
No error!

END_PGML
};

ENDDOCUMENT();

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

Successfully merging this pull request may close these issues.

3 participants