0
$\begingroup$

This question is related to Zero-dimensional matrices, in particular to the answer https://mathematica.stackexchange.com/a/39543/42722.

In Mathematica $0 \times n$-matrices are not well-defined, so I extended the definitions of Dimensions, Dot, Transpose ,Join, ... to a function emptyMatrix[n], which should represent an $0 \times n$-matrix for $n\geq 0$.

For example, we have Transpose[emptyMatrix[n]]=ConstantArray[{},n] and so on. This works all quite well, except that Transpose[ConstantArray[{},n]] in Mathematica gives {}, so in this case I need to redefine (instead of simply extending) the function Transpose on $n \times 0$-matrices.

Is this possible?

$\endgroup$
3
  • 2
    $\begingroup$ Do you absolutely need to use system functions? Otherwise this will do transpose[expr_] := Transpose[expr]; transpose[list : {{} ..}] := emptyMatrix[Length[list]]; $\endgroup$
    – Batracos
    Mar 18, 2020 at 10:36
  • $\begingroup$ aha, I didn't think of that.. thx! probably I don't need system functions. If Transpose is used in some other system function I'm using, then I could do the same trick again, I guess $\endgroup$ Mar 18, 2020 at 10:40
  • $\begingroup$ The alternative is to Unprotect and use the same definition on Transpose. I won't make any promise on that not introducing weird bugs though =) $\endgroup$
    – Batracos
    Mar 18, 2020 at 10:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.