Define different actions for the same operator depending on the nature of its argumentsHow to define the tangent gradient operator?How can I make threading more flexible?How to construct custom operators with precedence?Construct a function whose definition depends on the values of its argumentsDefine an operator with the distributive propertyReplacing multiplication of matrix elements by application of these elements as functionsDefining a matrix with elements acting as operatorsDefine an operator for FileNameJoinUsing Two Arguments on the Same FunctionHow to define custom differential operator using the arguments of the expression?

Theorems like the Lovász Local Lemma?

2D counterpart of std::array in C++17

Fill color and outline color with the same value

Be in awe of my brilliance!

Informing my boss about remarks from a nasty colleague

Why must traveling waves have the same amplitude to form a standing wave?

My adviser wants to be the first author

Bash: What does "masking return values" mean?

Make a transparent 448*448 image

Where is the 1/8 CR apprentice in Volo's Guide to Monsters?

I need to drive a 7/16" nut but am unsure how to use the socket I bought for my screwdriver

Russian cases: A few examples, I'm really confused

How to deal with taxi scam when on vacation?

Is a lawful good "antagonist" effective?

Why did it take so long to abandon sail after steamships were demonstrated?

Counting certain elements in lists

RegionDifference for Cylinder and Cuboid

Can elves maintain concentration in a trance?

Do I need life insurance if I can cover my own funeral costs?

Brexit - No Deal Rejection

Why is stat::st_size 0 for devices but at the same time lseek defines the device size correctly?

How to simplify this time periods definition interface?

Can the damage from a Talisman of Pure Good (or Ultimate Evil) be non-lethal?

Replacing Windows 7 security updates with anti-virus?



Define different actions for the same operator depending on the nature of its arguments


How to define the tangent gradient operator?How can I make threading more flexible?How to construct custom operators with precedence?Construct a function whose definition depends on the values of its argumentsDefine an operator with the distributive propertyReplacing multiplication of matrix elements by application of these elements as functionsDefining a matrix with elements acting as operatorsDefine an operator for FileNameJoinUsing Two Arguments on the Same FunctionHow to define custom differential operator using the arguments of the expression?













1












$begingroup$


I am working with terms of the form



A**B1**B2


where A, B1, and B2 are at this point abstract operators and ** means NonCommutativeMultiply.



I'd like to manipulate these expressions at an abstract level, and then only later substitute explicit matrix operations. Specifically, $A$ will be a square matrix, while $B1$ and $B2$ will be commensurate vectors.



The trick is that at this point the specific meanings of the two occurrences of ** will change. Specifically, A ** B1 will become a matrix multiplication, and B1 ** B2 will become an outer product.



I'm using a package (NCAlgebra) to simplify the expressions at an abstract level, and I want the special handling of NonCommutativeMultiply to apply then. So it would be good if there were some way to create an operation that behaves in all respects as NonCommutativeMultiply (so that the package still recognizes it as such), except in a certain function of my design (so that it gets substituted for the correct explicit operation).



Is there a way I can accomplish this?



Edit: A perhaps-important complication is that in the general case, once made explicit the matrix dimensions will be such that the matrix multiplication A ** B1 will not be defined until the outer product B1 ** B2 has been performed.










share|improve this question











$endgroup$











  • $begingroup$
    How are we supposed to distinguish between matrix multiplication and outer product? It looks the same to me.
    $endgroup$
    – Somos
    4 hours ago










  • $begingroup$
    Do you mean mathematically or in the code? Mathematically the two vectors are mapped by the outer product to a square matrix. In the code we would need to create a new function for at least one. I would like that function to behave as NonCommutativeMultiply, except when otherwise specified.
    $endgroup$
    – AGML
    4 hours ago










  • $begingroup$
    All I see is A**B1**B2 and the two ** look the same to me. How are we supposed to know that they are supposed to be different?
    $endgroup$
    – Somos
    4 hours ago











  • $begingroup$
    We of course cannot, at present. To solve the problem one of the two ** needs to be replaced by a new function. I have used ** in both cases because I want the new function to match the same existing patterns as ** would.
    $endgroup$
    – AGML
    4 hours ago










  • $begingroup$
    Alternatively, ** could be used in both cases, but the replacement rule could e.g. substitute an outer product only when the inner product is not defined, or something along those lines.
    $endgroup$
    – AGML
    4 hours ago















1












$begingroup$


I am working with terms of the form



A**B1**B2


where A, B1, and B2 are at this point abstract operators and ** means NonCommutativeMultiply.



I'd like to manipulate these expressions at an abstract level, and then only later substitute explicit matrix operations. Specifically, $A$ will be a square matrix, while $B1$ and $B2$ will be commensurate vectors.



The trick is that at this point the specific meanings of the two occurrences of ** will change. Specifically, A ** B1 will become a matrix multiplication, and B1 ** B2 will become an outer product.



I'm using a package (NCAlgebra) to simplify the expressions at an abstract level, and I want the special handling of NonCommutativeMultiply to apply then. So it would be good if there were some way to create an operation that behaves in all respects as NonCommutativeMultiply (so that the package still recognizes it as such), except in a certain function of my design (so that it gets substituted for the correct explicit operation).



Is there a way I can accomplish this?



Edit: A perhaps-important complication is that in the general case, once made explicit the matrix dimensions will be such that the matrix multiplication A ** B1 will not be defined until the outer product B1 ** B2 has been performed.










share|improve this question











$endgroup$











  • $begingroup$
    How are we supposed to distinguish between matrix multiplication and outer product? It looks the same to me.
    $endgroup$
    – Somos
    4 hours ago










  • $begingroup$
    Do you mean mathematically or in the code? Mathematically the two vectors are mapped by the outer product to a square matrix. In the code we would need to create a new function for at least one. I would like that function to behave as NonCommutativeMultiply, except when otherwise specified.
    $endgroup$
    – AGML
    4 hours ago










  • $begingroup$
    All I see is A**B1**B2 and the two ** look the same to me. How are we supposed to know that they are supposed to be different?
    $endgroup$
    – Somos
    4 hours ago











  • $begingroup$
    We of course cannot, at present. To solve the problem one of the two ** needs to be replaced by a new function. I have used ** in both cases because I want the new function to match the same existing patterns as ** would.
    $endgroup$
    – AGML
    4 hours ago










  • $begingroup$
    Alternatively, ** could be used in both cases, but the replacement rule could e.g. substitute an outer product only when the inner product is not defined, or something along those lines.
    $endgroup$
    – AGML
    4 hours ago













1












1








1





$begingroup$


I am working with terms of the form



A**B1**B2


where A, B1, and B2 are at this point abstract operators and ** means NonCommutativeMultiply.



I'd like to manipulate these expressions at an abstract level, and then only later substitute explicit matrix operations. Specifically, $A$ will be a square matrix, while $B1$ and $B2$ will be commensurate vectors.



The trick is that at this point the specific meanings of the two occurrences of ** will change. Specifically, A ** B1 will become a matrix multiplication, and B1 ** B2 will become an outer product.



I'm using a package (NCAlgebra) to simplify the expressions at an abstract level, and I want the special handling of NonCommutativeMultiply to apply then. So it would be good if there were some way to create an operation that behaves in all respects as NonCommutativeMultiply (so that the package still recognizes it as such), except in a certain function of my design (so that it gets substituted for the correct explicit operation).



Is there a way I can accomplish this?



Edit: A perhaps-important complication is that in the general case, once made explicit the matrix dimensions will be such that the matrix multiplication A ** B1 will not be defined until the outer product B1 ** B2 has been performed.










share|improve this question











$endgroup$




I am working with terms of the form



A**B1**B2


where A, B1, and B2 are at this point abstract operators and ** means NonCommutativeMultiply.



I'd like to manipulate these expressions at an abstract level, and then only later substitute explicit matrix operations. Specifically, $A$ will be a square matrix, while $B1$ and $B2$ will be commensurate vectors.



The trick is that at this point the specific meanings of the two occurrences of ** will change. Specifically, A ** B1 will become a matrix multiplication, and B1 ** B2 will become an outer product.



I'm using a package (NCAlgebra) to simplify the expressions at an abstract level, and I want the special handling of NonCommutativeMultiply to apply then. So it would be good if there were some way to create an operation that behaves in all respects as NonCommutativeMultiply (so that the package still recognizes it as such), except in a certain function of my design (so that it gets substituted for the correct explicit operation).



Is there a way I can accomplish this?



Edit: A perhaps-important complication is that in the general case, once made explicit the matrix dimensions will be such that the matrix multiplication A ** B1 will not be defined until the outer product B1 ** B2 has been performed.







function-construction operators argument-patterns






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago







AGML

















asked 5 hours ago









AGMLAGML

1557




1557











  • $begingroup$
    How are we supposed to distinguish between matrix multiplication and outer product? It looks the same to me.
    $endgroup$
    – Somos
    4 hours ago










  • $begingroup$
    Do you mean mathematically or in the code? Mathematically the two vectors are mapped by the outer product to a square matrix. In the code we would need to create a new function for at least one. I would like that function to behave as NonCommutativeMultiply, except when otherwise specified.
    $endgroup$
    – AGML
    4 hours ago










  • $begingroup$
    All I see is A**B1**B2 and the two ** look the same to me. How are we supposed to know that they are supposed to be different?
    $endgroup$
    – Somos
    4 hours ago











  • $begingroup$
    We of course cannot, at present. To solve the problem one of the two ** needs to be replaced by a new function. I have used ** in both cases because I want the new function to match the same existing patterns as ** would.
    $endgroup$
    – AGML
    4 hours ago










  • $begingroup$
    Alternatively, ** could be used in both cases, but the replacement rule could e.g. substitute an outer product only when the inner product is not defined, or something along those lines.
    $endgroup$
    – AGML
    4 hours ago
















  • $begingroup$
    How are we supposed to distinguish between matrix multiplication and outer product? It looks the same to me.
    $endgroup$
    – Somos
    4 hours ago










  • $begingroup$
    Do you mean mathematically or in the code? Mathematically the two vectors are mapped by the outer product to a square matrix. In the code we would need to create a new function for at least one. I would like that function to behave as NonCommutativeMultiply, except when otherwise specified.
    $endgroup$
    – AGML
    4 hours ago










  • $begingroup$
    All I see is A**B1**B2 and the two ** look the same to me. How are we supposed to know that they are supposed to be different?
    $endgroup$
    – Somos
    4 hours ago











  • $begingroup$
    We of course cannot, at present. To solve the problem one of the two ** needs to be replaced by a new function. I have used ** in both cases because I want the new function to match the same existing patterns as ** would.
    $endgroup$
    – AGML
    4 hours ago










  • $begingroup$
    Alternatively, ** could be used in both cases, but the replacement rule could e.g. substitute an outer product only when the inner product is not defined, or something along those lines.
    $endgroup$
    – AGML
    4 hours ago















$begingroup$
How are we supposed to distinguish between matrix multiplication and outer product? It looks the same to me.
$endgroup$
– Somos
4 hours ago




$begingroup$
How are we supposed to distinguish between matrix multiplication and outer product? It looks the same to me.
$endgroup$
– Somos
4 hours ago












$begingroup$
Do you mean mathematically or in the code? Mathematically the two vectors are mapped by the outer product to a square matrix. In the code we would need to create a new function for at least one. I would like that function to behave as NonCommutativeMultiply, except when otherwise specified.
$endgroup$
– AGML
4 hours ago




$begingroup$
Do you mean mathematically or in the code? Mathematically the two vectors are mapped by the outer product to a square matrix. In the code we would need to create a new function for at least one. I would like that function to behave as NonCommutativeMultiply, except when otherwise specified.
$endgroup$
– AGML
4 hours ago












$begingroup$
All I see is A**B1**B2 and the two ** look the same to me. How are we supposed to know that they are supposed to be different?
$endgroup$
– Somos
4 hours ago





$begingroup$
All I see is A**B1**B2 and the two ** look the same to me. How are we supposed to know that they are supposed to be different?
$endgroup$
– Somos
4 hours ago













$begingroup$
We of course cannot, at present. To solve the problem one of the two ** needs to be replaced by a new function. I have used ** in both cases because I want the new function to match the same existing patterns as ** would.
$endgroup$
– AGML
4 hours ago




$begingroup$
We of course cannot, at present. To solve the problem one of the two ** needs to be replaced by a new function. I have used ** in both cases because I want the new function to match the same existing patterns as ** would.
$endgroup$
– AGML
4 hours ago












$begingroup$
Alternatively, ** could be used in both cases, but the replacement rule could e.g. substitute an outer product only when the inner product is not defined, or something along those lines.
$endgroup$
– AGML
4 hours ago




$begingroup$
Alternatively, ** could be used in both cases, but the replacement rule could e.g. substitute an outer product only when the inner product is not defined, or something along those lines.
$endgroup$
– AGML
4 hours ago










1 Answer
1






active

oldest

votes


















3












$begingroup$

If I understand your question correctly, then the ** can be given a definition to do what you want. This code may work for you



Unprotect[NonCommutativeMultiply];
ClearAll[NonCommutativeMultiply];
NonCommutativeMultiply[x_?NumericQ, y_?NumericQ] := x * y;
NonCommutativeMultiply[x_?MatrixQ, y_?MatrixQ] := x . y;
NonCommutativeMultiply[x_?ListQ, y_?ListQ] := Outer[Times, x, y];


You can add more checking in the code as you need to.






share|improve this answer









$endgroup$












  • $begingroup$
    Yes, that should work I think. Thank you!
    $endgroup$
    – AGML
    4 hours ago










Your Answer





StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193255%2fdefine-different-actions-for-the-same-operator-depending-on-the-nature-of-its-ar%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3












$begingroup$

If I understand your question correctly, then the ** can be given a definition to do what you want. This code may work for you



Unprotect[NonCommutativeMultiply];
ClearAll[NonCommutativeMultiply];
NonCommutativeMultiply[x_?NumericQ, y_?NumericQ] := x * y;
NonCommutativeMultiply[x_?MatrixQ, y_?MatrixQ] := x . y;
NonCommutativeMultiply[x_?ListQ, y_?ListQ] := Outer[Times, x, y];


You can add more checking in the code as you need to.






share|improve this answer









$endgroup$












  • $begingroup$
    Yes, that should work I think. Thank you!
    $endgroup$
    – AGML
    4 hours ago















3












$begingroup$

If I understand your question correctly, then the ** can be given a definition to do what you want. This code may work for you



Unprotect[NonCommutativeMultiply];
ClearAll[NonCommutativeMultiply];
NonCommutativeMultiply[x_?NumericQ, y_?NumericQ] := x * y;
NonCommutativeMultiply[x_?MatrixQ, y_?MatrixQ] := x . y;
NonCommutativeMultiply[x_?ListQ, y_?ListQ] := Outer[Times, x, y];


You can add more checking in the code as you need to.






share|improve this answer









$endgroup$












  • $begingroup$
    Yes, that should work I think. Thank you!
    $endgroup$
    – AGML
    4 hours ago













3












3








3





$begingroup$

If I understand your question correctly, then the ** can be given a definition to do what you want. This code may work for you



Unprotect[NonCommutativeMultiply];
ClearAll[NonCommutativeMultiply];
NonCommutativeMultiply[x_?NumericQ, y_?NumericQ] := x * y;
NonCommutativeMultiply[x_?MatrixQ, y_?MatrixQ] := x . y;
NonCommutativeMultiply[x_?ListQ, y_?ListQ] := Outer[Times, x, y];


You can add more checking in the code as you need to.






share|improve this answer









$endgroup$



If I understand your question correctly, then the ** can be given a definition to do what you want. This code may work for you



Unprotect[NonCommutativeMultiply];
ClearAll[NonCommutativeMultiply];
NonCommutativeMultiply[x_?NumericQ, y_?NumericQ] := x * y;
NonCommutativeMultiply[x_?MatrixQ, y_?MatrixQ] := x . y;
NonCommutativeMultiply[x_?ListQ, y_?ListQ] := Outer[Times, x, y];


You can add more checking in the code as you need to.







share|improve this answer












share|improve this answer



share|improve this answer










answered 4 hours ago









SomosSomos

1,42519




1,42519











  • $begingroup$
    Yes, that should work I think. Thank you!
    $endgroup$
    – AGML
    4 hours ago
















  • $begingroup$
    Yes, that should work I think. Thank you!
    $endgroup$
    – AGML
    4 hours ago















$begingroup$
Yes, that should work I think. Thank you!
$endgroup$
– AGML
4 hours ago




$begingroup$
Yes, that should work I think. Thank you!
$endgroup$
– AGML
4 hours ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Mathematica Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193255%2fdefine-different-actions-for-the-same-operator-depending-on-the-nature-of-its-ar%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identifying “long and narrow” polygons in with PostGISlength and width of polygonWhy postgis st_overlaps reports Qgis' “avoid intersections” generated polygon as overlapping with others?Adjusting polygons to boundary and filling holesDrawing polygons with fixed area?How to remove spikes in Polygons with PostGISDeleting sliver polygons after difference operation in QGIS?Snapping boundaries in PostGISSplit polygon into parts adding attributes based on underlying polygon in QGISSplitting overlap between polygons and assign to nearest polygon using PostGIS?Expanding polygons and clipping at midpoint?Removing Intersection of Buffers in Same Layers

Masuk log Menu navigasi

อาณาจักร (ชีววิทยา) ดูเพิ่ม อ้างอิง รายการเลือกการนำทาง10.1086/39456810.5962/bhl.title.447410.1126/science.163.3863.150576276010.1007/BF01796092408502"Phylogenetic structure of the prokaryotic domain: the primary kingdoms"10.1073/pnas.74.11.5088432104270744"Towards a natural system of organisms: proposal for the domains Archaea, Bacteria, and Eucarya"1990PNAS...87.4576W10.1073/pnas.87.12.4576541592112744PubMedJump the queueexpand by handPubMedJump the queueexpand by handPubMedJump the queueexpand by hand"A revised six-kingdom system of life"10.1111/j.1469-185X.1998.tb00030.x9809012"Only six kingdoms of life"10.1098/rspb.2004.2705169172415306349"Kingdoms Protozoa and Chromista and the eozoan root of the eukaryotic tree"10.1098/rsbl.2009.0948288006020031978เพิ่มข้อมูล