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

mpinv isn't broadcasting #20

Open
KJ7LNW opened this issue Aug 2, 2022 · 1 comment
Open

mpinv isn't broadcasting #20

KJ7LNW opened this issue Aug 2, 2022 · 1 comment

Comments

@KJ7LNW
Copy link

KJ7LNW commented Aug 2, 2022

I could be wrong here, but I sort of think that mpinv() should function about the same as minv() --- but broadcasting fails for mpinv():

minv() broadcasts the inverse:

pdl> $p = sequence(2,2,5)
pdl> p $p->minv
[
 [
  [-1.5  0.5]
  [   1    0]
 ]
 [
  [      -3.5        2.5]
  [         3         -2]
 ]
 [
  [      -5.5        4.5]
  [         5         -4]
 ]
...
]

whereas mpinv() blows up when trying the pseudo-inverse:

pdl> p $p->mpinv
PDL: PDL::Ops::gt(a,b,c): Parameter 'b':
  Mismatched implicit broadcast dimension 0: size 2 vs. 5
There are 3 PDLs in the expression; 2 broadcast dims.
   PDL IN EXPR.    BROADCAST DIMS
   #  0 (normal):        2       5
   #  1 (normal):        5
   #  2 (null)

.. at ops.pd line 136.
	PDL::Ops::__ANON__(PDL=SCALAR(0x564b231f17a0), PDL=SCALAR(0x564b23290390), "") called at /usr/local/lib64/perl5/PDL/LinearAlgebra.pm line 926
	PDL::mpinv(PDL=SCALAR(0x564b232406c8)) called at (eval 65) line 4
	main::__ANON__() called at /usr/local/bin/perldl line 682
	eval {...} called at /usr/local/bin/perldl line 682
	main::eval_and_report("p \$p->mpinv\x{a}") called at /usr/local/bin/perldl line 618
	main::process_input() called at /usr/local/bin/perldl line 638
	eval {...} called at /usr/local/bin/perldl line 638
@mohawk2
Copy link
Member

mohawk2 commented Aug 6, 2022

As noted on IRC:

the starting-point would be to enhance runtest so that the 1st ndarray param routinely also got tested in both real and complex mode, having had a dummy-dim added at the top with value 2. that would shake out all the non-broadcast-capable functions at once
[...]
fixing things to work for broadcasting is quite a fun exercise to force oneself to think n-dimensionally

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