Home > matgraph > @permutation > mpower.m

mpower

PURPOSE ^

p^t is p multiplied by itself t times. May have t <= 0.

SYNOPSIS ^

function q = mpower(p,t)

DESCRIPTION ^

 p^t is p multiplied by itself t times. May have t <= 0.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function q = mpower(p,t)
0002 % p^t is p multiplied by itself t times. May have t <= 0.
0003 if t==0
0004     q = permutation(length(p));
0005     return
0006 end
0007 
0008 if t<0
0009     q = (inv(p))^(-t);
0010     return
0011 end
0012 
0013 if t == 1
0014     q = p;
0015 end
0016 
0017 % recurse when t>1
0018 
0019 if mod(t,2) == 0
0020     q = p^(t/2);
0021     q = q*q;
0022 else
0023     q = p^((t-1)/2);
0024     q = p*q*q;
0025 end

Generated on Thu 13-Mar-2008 14:23:52 by m2html © 2003