File: roll.htm

package info (click to toggle)
extrema 4.4.4.dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 19,416 kB
  • ctags: 6,689
  • sloc: cpp: 88,991; sh: 8,229; makefile: 480
file content (82 lines) | stat: -rw-r--r-- 3,244 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<HTML>
<HEAD>
<TITLE>ROLL</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF" fgcolor="#000000">

<P><A NAME="roll"></A>
<font size="+3" color="green"><B>ROLL</B></font></P>
<P>
<TABLE border="1" cols="2" frame="box" rules="all" width="572">
<TR>
<TD width="15%" valign="top"><B>Syntax</B>:</TD>
<TD width="85%"><CODE>
vector = ROLL( vector, scalar )<br />
matrix = ROLL( matrix, scalar )</CODE>
</TD></TR>
</table></p>
<p>
 The <CODE>ROLL</CODE> function accepts either a vector or a matrix
 as its first argument. It shifts the elements of a vector or the rows of a matrix by the
 specified step size, the scalar second argument.</p>
<P>
 Suppose the step size is <i>n</i>.</P>
<P>
 <table>
 <tr>
 <td valign="top">&bull;</td><td>If <i>n</i> &gt; 0, the last <i>n</i> elements of the vector
 or the last <i>n</i> rows of the matrix are rolled around to the beginning.</td>
 </tr><tr>
 <td valign="top">&bull;</td><td>If <i>n</i> = 0, the vector or matrix is returned unchanged.</td>
 </tr><tr>
 <td valign="top">&bull;</td><td>If <i>n</i> &lt; 0, the first <i>n</i> elements of the vector
 or the first <i>n</i> rows of the matrix are rolled around to the end.</td>
 </tr></table></P>
<P>
 If the step size is not an integer, then linear interpolation is used to generate new
 values.</P>
<P>
 <font size="+1" color="green">Examples</font></P>
<P>
 <table>
 <tr>
 <td bgcolor="#FFCCCC"><i>function</i></td><td bgcolor="#FFCCCC"><i>result</i></td>
 </tr><tr>
 <td><CODE><font color="blue">ROLL([1:10],2)</font></CODE></td>
 <td bgcolor="#FFFFCC"><CODE>[9;10;1;2;3;4;5;6;7;8]</CODE></td>
 </tr><tr>
 <td><CODE><font color="blue">ROLL([1:10],-2)</font></CODE></td>
 <td bgcolor="#FFFFCC"><CODE>[3;4;5;6;7;8;9;10;1;2]</CODE></td>
 </tr><tr>
 <td><CODE><font color="blue">ROLL([1:10],1.7)</font></CODE></td>
 <td bgcolor="#FFFFCC"><CODE>[9.3;7.3;1.3;2.3;3.3;4.3;5.3;6.3;7.3;8.3]</CODE></td>
 </tr></table></P>
<P>
 Suppose you have a matrix <CODE>M</CODE><br />
 <pre>
            | 1  2  3  4 |
        M = | 5  6  7  8 |
            | 9 10 11 12 |
 </pre></P>
<P>
 <table>
 <tr>
 <td bgcolor="#FFCCCC"><i>function</i></td><td bgcolor="#FFCCCC"><center><i>result</i></center></td>
 </tr><tr>
 <td valign="middle"><CODE><font color="blue">ROLL(M,2)</font></CODE></td>
 <td bgcolor="#FFFFCC"><table cellspacing="0"><tr><td><code>| 5&nbsp; 6&nbsp; 7&nbsp; 8 |</code></td></tr>
            <tr><td><code>| 9 10 11 12 |</code></td></tr>
            <tr><td><code>| 1&nbsp; 2&nbsp; 3&nbsp; 4 |</code></td></tr></table></td>
 </tr><tr><td></td><td></td></tr><tr>
 <td valign="middle"><CODE><font color="blue">ROLL(M,-1)</font></CODE></td>
 <td bgcolor="#FFFFCC"><table cellspacing="0"><tr><td><CODE>| 5&nbsp; 6&nbsp; 7&nbsp; 8 |</CODE></td></tr>
            <tr><td><CODE>| 9 10 11 12 |</CODE></td></tr>
            <tr><td><CODE>| 1&nbsp; 2&nbsp; 3&nbsp; 4 |</CODE></td></tr></table></td>
 </tr><tr><td></td><td></td></tr><tr>
 <td valign="middle"><CODE><font color="blue">ROLL(M,1.5)</font></CODE></td>
 <td bgcolor="#FFFFCC"><table cellspacing="0"><tr><td><CODE>| 7 8 9 10 |</CODE></td></tr>
            <tr><td><CODE>| 5 6 7&nbsp; 8 |</CODE></td></tr>
            <tr><td><CODE>| 3 4 5&nbsp; 6 |</CODE></td></tr></table></td>
 </tr></table></P>
</BODY>
</HTML>