File: fold.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 (55 lines) | stat: -rw-r--r-- 2,066 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
<HTML>
<HEAD>
<TITLE>FOLD</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF" fgcolor="#000000">

<P><A NAME="fold"></A>
<font size="+3" color="green"><B>FOLD</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>
matrix = FOLD( vector, scalar )</CODE>
</TD></TR>
</table></p>
<p>
 The <CODE>FOLD</CODE> function has two arguments. The first
 must be a vector, and the second a scalar. The result is a matrix formed by folding the
 data in the vector into the columns of a matrix.</P>
<P>
 Suppose that vector <CODE>x</CODE> has <CODE>m</CODE> elements. Then</P>
<P>
 <CODE>FOLD(x,n)[i,j] = x[i+(j-1)*n]</CODE></P>
<P>
 for <CODE>i = 1,2,...,n</CODE> and <CODE>j = 1,2,...,m/n</CODE>.</P>
<P>
 Note that <CODE>m</CODE> must be divisible by <CODE>n</CODE>.</P>
<P>
 <font size="+1" color="green">Examples</font></P>
<P>
 If <CODE>M</CODE> is a matrix with <CODE>R</CODE> rows, then
 <CODE>FOLD(UNFOLD(M),R)</code> is equal to <code>M</CODE>.</p>
<p>
 If <CODE>X</CODE> is a vector and <CODE>N</CODE> is a scalar such than
 <CODE>LEN(X)</CODE> is divisible by <CODE>N</CODE>, then
 <CODE>UNFOLD(FOLD(X,N))</code> is equal to <code>X</CODE>.</p>
<P>
 <table>
 <tr>
 <td bgcolor="#FFCCCC"><i>function</i></td><td bgcolor="#FFCCCC"><i>result</i></td>
 </tr><tr>
 <td valign="middle"><CODE><font color="blue">FOLD([1:12],3)</font></CODE></td>
 <td bgcolor="#FFFFCC"><table cellspacing="0"><tr><td><CODE>| 1 4 7 10 |</CODE></td></tr>
            <tr><td><CODE>| 2 5 8 11 |</CODE></td></tr>
            <tr><td><CODE>| 3 6 9 12 |</CODE></td></tr></table></td>
 </tr><tr><td></td><td></td></tr><tr>
 <td valign="middle"><CODE><font color="blue">FOLD([1:12],4)</font></CODE></td>
 <td bgcolor="#FFFFCC"><table cellspacing="0"><tr><td><CODE>| 1 5&nbsp; 9 |</CODE></td></tr>
            <tr><td><CODE>| 2 6 10 |</CODE></td></tr>
            <tr><td><CODE>| 3 7 11 |</CODE></td></tr>
            <tr><td><CODE>| 4 8 12 |</CODE></td></tr></table></td>
 </tr></table></P>
</BODY>
</HTML>