Adept Scientific - English
The world's best software and hardware for research, science and engineering.
flag arrow
clearclear

 Adept Store | register Join My Adept | Flags  
Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055  
UKdedksvnofi
Home
Products
Training
Events
 Buy Online
Downloads
Academic Discounts
Support
My Adept
International |  About Us |  Adept Scientific Blog |  Contact Us |  Press Room |  Jobs
Adept Scientific on Facebook Adept Scientific on Twitter Adept Scientific on YouBube Adept Scientific on LinkedIn


The Next Steps

• Ask us a question
• Watch Maple Video Demonstrations
• Buy Maple Now
• View Maple Pricing
• Download a Brochure
• Request a Brochure
• Request an Evaluation
• Meet Our Team
• Read our RSS Feeds

Learn More

Maple Home
Maple 16 Overview
Maple 16 Professional
Maple 16 Academic
Maple 16 Student Use
What's New in Maple 16
Maple New Features
Datasheet

Maple History
Recorded Online Seminars

MapleSim
MapleNet
Maple T.A.
BlockImporter™
Maple Toolboxes

Maple Rave Reviews
Maple Study Guides
Books about Maple
System Requirements

Latest Information

New Features: Professional
New Features: Academic
Maple Features
The Maple Reporter Online

Service & Support

Maple Primes
blogs, forums etc

Elite Maintenance Program
Application Centre
Powertools
Search the Knowledge Base
Technical Support request

List Archives >  Maple User Group List Archive >  Archive by date >  This Month By Date >  This Month By Topic

[MUG] Rings ...

Search email archive for  

[MUG] Rings ...
Author: L C G Rogers    Posted: 14/11/2000 17:48:12 GMT
>> From: L C G Rogers

Is there any way in Maple to do symbolic manipulation
without the assumption that a*b=b*a?

-----------------------------------------------------------------------
L C G Rogers, Professor of Probability tel:+44 1225 826224
Department of Mathematical Sciences fax:+44 1225 826492
University of Bath, Bath BA2 7AY, GB

Email: web: www.bath.ac.uk/~maslcgr/home.html
-----------------------------------------------------------------------

[MUG] Re: Rings ...
Author: Maple Group    Posted: 20/11/2000 16:24:00 GMT
>> From: Maple Group

| >> From: L C G Rogers
|
| Is there any way in Maple to do symbolic manipulation
| without the assumption that a*b=b*a?
|

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Thu, 16 Nov 2000 11:05:51 +0100
From: Maerivoet Roland
To:
Subject: Rings ...

You could use the matrixoperator &*

Roland Maerivoet
Applied Informatics
Hogeschool Gent

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Thu, 16 Nov 2000 13:01:39 +0000
From: "Dr Francis J. Wright"
To:
Subject: Rings ...

The standard non-commutative multiplication operator is &* (and . in
maple6).

Francis

--

Dr Francis J. Wright | mailto:
School of Mathematical Sciences | tel: (020) 7882 5453 (direct)
Queen Mary, University of London | fax: (020) 8981 9587 (dept.)
Mile End Road, London E1 4NS, UK | http://centaur.maths.qmw.ac.uk/


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: Douglas Wilhelm Harder
Subject: Rings ...
To:
Date: Thu, 16 Nov 2000 11:38:15 -0500 (EST)

Hello,

In Maple6, you can use modules to override operators. Here is an example of
a ring of 2x2 matrices module 19 which overrides +, * and -, and it recognizes
the special ring members 0 and 1. Once you have done 'with(Matrix22mod19);',
the call:

> A * B;

is immediately converted to `*`( A, B ) and so there you may decide whether or
not * should be commutative.

> Matrix22mod19 := module()
export `*`, `+`, `-`;

`*` := proc( A::{Matrix(integer), 0, 1}, B::{Matrix(integer), 0, 1} )
local result;

if (member( A, {0, 1} ) or LinearAlgebra[Dimensions]( A ) = (2, 2)) and
(member( B, {0, 1} ) or LinearAlgebra[Dimensions]( B ) = (2, 2)) then
if A = 0 then
0;
elif B = 0 then
0;
elif A = 1 and B = 1 then
1;
elif A = 1 then
LinearAlgebra[Map]( `modp`, B, 19 );
elif B = 1 then
LinearAlgebra[Map]( `modp`, A, 19 );
else
result := Matrix( [[(A[1,1] * B[1,1] + A[1,2] * B[2,1]) mod 19,
(A[1,1] * B[1,2] + A[1,2] * B[2,2]) mod 19],
[(A[1,1] * B[1,1] + A[1,2] * B[2,1]) mod 19,
(A[1,1] * B[1,2] + A[1,2] * B[2,2]) mod 19]] );

if LinearAlgebra[Equal]( result, Matrix([[0,0],[0,0]]) ) then
0;
elif LinearAlgebra[Equal]( result, Matrix([[1,0],[0,1]]) ) then
1;
else
result;
end if;
end if;
else
error "expecting 2 by 2 matrices";
end if;
end proc;

`-` := proc( A::{Matrix(integer), 0, 1} )
local result;

if A = 0 then
0;
elif A = 1 then
Matrix( [[18, 0], [0, 18]] );
elif LinearAlgebra[Dimensions]( A ) = (2, 2) then
result := map( `modp`, map( :-`-`, A ), 19 );

if LinearAlgebra[Equal]( result, Matrix([[0,0],[0,0]]) ) then
0;
elif LinearAlgebra[Equal]( result, Matrix([[1,0],[0,1]]) ) then
1;
else
result;
end if;
else
error "expecting a 2 by 2 matrix";
end if;
end proc;

`+` := proc( A::{Matrix(integer), 0, 1}, B::{Matrix(integer), 0, 1} )
local result;

if (member( A, {0, 1} ) or LinearAlgebra[Dimensions]( A ) = (2, 2)) and
(member( B, {0, 1} ) or LinearAlgebra[Dimensions]( B ) = (2, 2)) then
if A = 0 and B = 0 then
0;
elif A = 1 then
procname( Matrix([[1,0],[0,1]]), B );
elif B = 1 then
procname( A, Matrix([[1,0],[0,1]]) );
elif A = 0 then
LinearAlgebra[Map]( `modp`, B, 19 );
elif B = 0 then
LinearAlgebra[Map]( `modp`, A, 19 );
else
result := Matrix( [[(A[1,1] + B[1,1]) mod 19,
(A[1,2] + B[1,2]) mod 19],
[(A[2,1] + B[2,1]) mod 19,
(A[2,2] + B[2,2]) mod 19]] );

if LinearAlgebra[Equal]( result, Matrix([[0,0],[0,0]]) ) then
0;
elif LinearAlgebra[Equal]( result, Matrix([[1,0],[0,1]]) ) then
1;
else
result;
end if;
end if;
else
error "expecting 2 by 2 matrices";
end if;
end proc;
end module:

So now you can do:

> with(Matrix22mod19);
[*, +, -]

> <<1,5>|<7,3>> + 1; # New short form for entering the new Matrices.
[2 7]
[ ]
[5 4]

> <<1,5>|<7,3>> * 1;
[1 7]
[ ]
[5 3]

> 1 + 1;
[2 0]
[ ]
[0 2]

> <<1,5>|<7,3>> * <<7,2>|<5,2>>;
[2 0]
[ ]
[2 0]

> <<7,2>|<5,2>> * <<1,5>|<7,3>>;
[13 7]
[ ]
[13 7]

> <<1,5>|<7,3>> * <<7,2>|<5,2>> + <<18, 17>|<0, 1>>;
1

> <<7,2>|<5,2>> * <<1,5>|<7,3>> - <<12, 13>|<7, 6>>;
1

> -<<1,5>|<7,3>>;
[18 12]
[ ]
[14 16]

> -1;
[18 0]
[ ]
[ 0 18]

Note that since you have overridden +, -, and *, you can no longer do
very much else:

> -3;
Error, - expects its 1st argument, A, to be of type {0, 1, Matrix(integer)},
but received 3
> 3 + 4;
Error, + expects its 1st argument, A, to be of type {0, 1, Matrix(integer)},
but received 3

so you might want to not just return an error if you get something other
than 0, 1, or a Matrix of type integer.

Hopefully this is somewhat useful.

Cheers,

Douglas


--
Douglas Wilhelm Harder ||\_ _\ /_/\_ _/\_\ /_ _/|| MM BSc MCpl (Retd)
University of Waterloo ||\ _\ /_/\_\ /_ _/
Waterloo Fractal Compression Project _\ / _/||
_/\_\||\_ _/ /_/\_
http://links.uwaterloo.ca/~douglas _/||\_ _/ /_/\



-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: "Willard, Daniel Dr DUSA-OR"
To:
Subject: Rings ...
Date: Thu, 16 Nov 2000 09:30:23 -0500

In the help section "evalm" (evaluate matrix expressions) you will find the
paragraph:

To indicate non-commutative matrix multiplication, use the operator &*. The
matrix product ABC may be entered as A &* B &* C or as &*(A,B,C), the latter
being more efficient. Automatic simplifications such as collecting constants
and powers will be applied. Do NOT use the * to indicate purely matrix
multiplication, as this will result in an error. The operands of &* must be
matrices (or names) with the exception of 0. Unevaluated matrix products are
considered to be matrices. The operator &* has the same precedence as the *
operator.



Previous by date: [MUG] MCMC Example?,  David Robinson
Next by date: [MUG] Re: Comments / Documentation, Maple Group
Previous thread: [MUG] neutral operator, Jean-Pierre Douris
Next thread: [MUG] Comments / Documentation,  Nathan Sokalski



Ready to buy?

For more pricing information:
Visit our webstore, call us on +1 800 724 8380 or email us at info@adeptscience.com

Featured Downloads

Maple 16 & MapleSim 5 Professional Brochure
Maple 16 Academic Datasheet
Maple 16 & MapleSim 5 Academic Brochure
Maple 16 What is New datasheet
Maple 16 Professional Datasheet
Maple Whitepaper: Driving Innovation - How mathematical modeling and optimisation increase efficiency and productivity in vehicle design.
MapleSim Whitepaper - Technological Superiority in Multi-Domain Physical Modelling and Simulation

Latest Downloads

Maple 16 Programming Guide
Maple 16 User Manual
Maple 16 Academic Datasheet
Maple 16 Professional Datasheet
Maple 16 & MapleSim 5 Academic Brochure

Product Reviews

"Without the Maple software, we would have to spend weeks generating the equations of motion for every experiment. Then the chances that we did it right would basically be near zero. There would always be a mistake somewhere. It is very difficult to set up a dynamic motion model by hand."
- Jean-Claude PiedBeouf, Ph.D Manager of Robotics, Canadian Space Agency

"Its very good - highly accurate and easy to use. The speed of Maple allows me to change equations and quickly reintegrate them into the application, so more possibilities can be explored to achieve the precise effect desired."
Shawn Neely, Senior R & D Director for PDI/Dreamworks

Latest News

Connectivity to major CAD systems extended in Maple 16
MapleSim Breaks New Ground in Hardware-in-the-Loop real-time simulation for planetary rovers
MapleSim Breaks New Ground in Hardware-in-the-Loop real-time simulation for planetary rovers
Maths software usability reaches new heights with Maple 16
"MapleSim was an eye-opener for us.
adept

Top of the Page

Popular Links: ChemDraw | ChemOffice | Data Acquisition | Data Analysis | EndNote | Maple | MapleSim | Mathcad | MathType | Quality Analyst | Reference Manager | VisSim

EU ePrivacy Directive | Our Privacy and Terms and Conditions Statement
All Trademarks Recognised. Copyright © 2012, Adept Scientific plc.
Site designed and maintained by Lyndon Ash

Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055