<div dir="ltr">I assume it's MKL sparse that fails for empty matrices, because the BLAS and LAPACK should follow the Netlib convention.<div><br></div><div>I'm sorry that MKL is unwilling to do nothing for you :-)<br><div><br></div><div><div>Jeff</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, May 30, 2020 at 4:26 PM Mills, Richard Tran via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov">petsc-dev@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
Thanks for the replies, everyone. It suppose is not actually that hard for me to handle these dimensions properly -- I just hadn't personally encountered or thought much about when such operations with empty matrices might arise, and was initially puzzled about
 what multiplication by an "empty" matrix even means. I think I see now why I need to put in the work to handle these cases properly. (Sure wish that MKL could just do it, though!)<br>
<br>
--Richard<br>
<br>
<div>On 5/30/20 4:09 PM, Stefano Zampini wrote:<br>
</div>
<blockquote type="cite">
<pre></pre>
<blockquote type="cite">
<pre>On May 31, 2020, at 1:03 AM, Jed Brown <a href="mailto:jed@jedbrown.org" target="_blank"><jed@jedbrown.org></a> wrote:

Stefano Zampini <a href="mailto:stefano.zampini@gmail.com" target="_blank"><stefano.zampini@gmail.com></a> writes:

</pre>
<blockquote type="cite">
<pre>If A is 0x8 and B is 8x5 then C is correct to be of size 0x5. The rows and columns of the resulting matrix have to follow the rules.
</pre>
</blockquote>
<pre>Right, I think if you said C is 0x0 (which seems like Richard's proposal), you'd need to relax shape compatibility logic in many places, including in ways that might produce confusing errors.

</pre>
</blockquote>
<pre>Richard

In the triple matrix product case, your code will break, because the operation will no longer be associative

A 3x0, B 0x8, C 8x7 -> (ABC) is a valid 3x7 matrix (empty) 

If I understand you right, (AB)  would be  a 0x0 matrix, and it can no longer be multiplied against C

</pre>
<blockquote type="cite">
<pre>Richard, what is the hardship in preserving the shape relations?
</pre>
</blockquote>
<pre></pre>
</blockquote>
<br>
</div>

</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Jeff Hammond<br><a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br><a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></div>