Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 6
    $\begingroup$ First of all, the operator . is not Times but Dot. Secondly, I wouldn't mess with the properties of such a fundamental operator. I suggest defining a new operator or using something like NonCommutativeMultiply, for which you can find several examples on StackExchange. $\endgroup$ Commented Jan 10, 2022 at 9:44
  • 1
    $\begingroup$ Thanks Domen, but I would like to clarify: between the two large matrices outside, it is dot product, which does not have the attributes of Orderless by default, but to work out the product in entry level, Dot[] will compute sub-product as entry in result matrices by Times[], that is the why I have to modify Times furthermore to get the correct result. $\endgroup$ Commented Jan 10, 2022 at 9:52
  • 3
    $\begingroup$ I would also recommend against changing a built-in, and maybe define your own version of Dot to use instead—consider using Inner, e.g. a = {{Indexed[A,{1,1}], 0}, {0, Indexed[A, {2,2}]}}; b = {{0,X},{Y,0}}; Inner[NonCommutativeMultiply, a, b, Plus]. Of course, you'd need to define NonCommutativeMultiply appropriately first, since it's nearly completely undefined by default, which is not a trivial task... $\endgroup$ Commented Jan 10, 2022 at 10:05
  • $\begingroup$ @thorimur That's definitely true, it is indeed not a trivial task since I have been stuck here for nearly one week. For such a seemingly simple thing, the Partitioned Matrix Algebra, it is counter-intuitively hard to teach mathematica to do it correctly, how ironic it is! $\endgroup$ Commented Jan 10, 2022 at 10:23
  • $\begingroup$ Changing attributes of the low level arithmetic functions Plus, Times and Power ranks high on the list of Things Not To Do. There is past discussion about this here. Generally one instead uses NonCommutativeMultiply, defining rules as needed. $\endgroup$ Commented Jan 10, 2022 at 15:10