def mdot(*args):
if len(args) == <NUM_LIT:1>:<EOL><INDENT>return args[<NUM_LIT:0>]<EOL><DEDENT>elif len(args) == <NUM_LIT:2>:<EOL><INDENT>return _mdot_r(args[<NUM_LIT:0>], args[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>return _mdot_r(args[:-<NUM_LIT:1>], args[-<NUM_LIT:1>])<EOL><DEDENT>
Multiply all the arguments using matrix product rules.
The output is equivalent to multiplying the arguments one by one
from left to right using dot().
Precedence can be controlled by creating tuples of arguments,
for instance mdot(a,((b,c),d)) multiplies a (a*((b*c)*d)).
Note that this means the output of dot(a,b) and mdot(a,b) will differ if
a or b is a pure tuple of numbers.