在 Mathematica 中以明确可见的形式显示
继续我的矩阵乘法问题 ,我想在 mma 中以显式可视形式显示以下表达式:
即使在在我给出 a11, ..., b11, ... 显式数字的情况下,我仍然希望它是未评估形式的 (0&&1)||(1&1) 。有人可以帮忙吗?
Continuing with my matrix multiplication question, I want to show the following expression in explicit viewable form in mma:
Even if in the case I give a11, ..., b11, ... explicit numbers, I still want it to be (0&&1)||(1&&1) in unevaluated form. Can anyone please help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
(0&&1)||(1&&1)
不评估,所以我没有看到问题。对于True
和False
您是否尝试过使用 HoldForm?(0&&1)||(1&&1)
does not evaluate, so I do not see the problem. ForTrue
andFalse
have you tried using HoldForm?实现此目的的一种方法是定义您自己的矩阵包装器。包装器方法的优点是您可以重载任意数量的内置函数,而不会影响任何其他功能。
让我们首先定义一个名为
myMatrix
的包装器,它使用MatrixForm
显示自身:接下来,我们将在
Times
运算符作用于时重载它。 >myMatrix
:请注意,这两个定义都使用
^:=
将规则作为上值附加到myMatrix
。这对于确保常规内置定义不受影响至关重要。有了这些定义,我们现在就可以实现预期的目标了。为了进行演示,我们定义两个矩阵:
现在可以生成所请求的“显式可见表单”:
。 .. 或者,如果您希望在等式左侧显式引用
Times
:接下来,我们将为每个矩阵元素分配随机布尔值:
...然后使用适当的分配再次生成显式可见的形式:
One way to achieve this is to define your own matrix wrapper. The wrapper approach has the advantage that you can overload as many built-in functions as you like without impacting any other functionality.
Let's start by defining a wrapper called
myMatrix
that displays itself usingMatrixForm
:Next, we'll overload the
Times
operator when it acts onmyMatrix
:Note that both definitions use
^:=
to attach the rules tomyMatrix
as up-values. This is crucial to ensure that the regular built-in definitions are otherwise unaffected.Armed with these definitions, we can now achieve the desired goal. To demonstrate, let's define two matrices:
The requested "explicitly viewable form" can now be generated thus:
... or, if you prefer to reference
Times
explicitly on the left-hand side of the equation:Next, we'll assign random boolean values to each of the matrix elements:
... and then generate the explicitly viewable form once again with the assignments in place:
使用
编辑。跟进您之前的问题后,我认为您可能会考虑
Use
Edit. Having followed up on your previous question, I think you might consider
我不认为这是一个真正的好主意(重载内部函数和所有;并且 && 不是 BitAnd,您想在上一个问题中使用它),但是您要求它并得到它:
< img src="https://i.sstatic.net/sK9tA.png" alt="新定义的 CircleTimes 的输出">
将操作定义为 CircleTimes 的优点是您可以免费获得 CircleTimes 符号和运算符。
I don't think this is a really good idea (overloading internal functions and all; and && is And not BitAnd, which you wanted to use in the previous question), but you asked for it and you get it:
The advantage of defining the operation as CircleTimes is that you get the CircleTimes symbol and operator for free.