Programmer Guide/Command Reference/EVAL/vsubn: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====vsubn=====
Extract rows from a vector or matrix.
;Usage: '''<code><var>vsubn(x</var> {, <var>o</var> {, <var>n</var>}})</code>'''
:;<var>x</var>: source vector or matrix
:;<var>o</var>: offset, 0 <= ''o'' < <code>nrow(''x'')</code>
:;<var>n</var>: length, ''n'' > 0 and ''o''+''n'' <= <code>nrow(''x'')</code>
;Result: A matrix with <code>nrow(''x1'')</code> columns. The columns of the arguments are merged from left to right into the rows of the result matrix. Note: <code>vmrow(a,b,c)</code> returns the same result as <code>trn(vmcol(a,b,c))</code>, but <code>vmrow</code> is faster and uses less memory than the nested command.
;See also: [[Programmer_Guide/Command_Reference/EVAL/vv|vv]], [[Programmer_Guide/Command_Reference/EVAL/vvset|vvget]], [[Programmer_Guide/Command_Reference/EVAL/vvset|vvset]], [[Programmer_Guide/Command_Reference/EVAL/vvcat|vvcat]], [[Programmer_Guide/Command_Reference/EVAL/vmcol|vmcol]], [[Programmer_Guide/Command_Reference/EVAL/vsubn|vsubn]], [[Programmer_Guide/Command_Reference/EVAL/vsubc|vsubc]]


Extract the subvector <var>x</var>[<var>o</var> .. <var>o</var>+<var>n</var>-1] from the vector <var>x</var>.
Example:
<pre>
#a := eval vv(1,2,3,4,5)
#b := eval init(5,2,0)
#c := eval vmcol($#a, $#b, $#a)
// -> $#c is a matrix with 4 rows and 5 columns:
//   $#c[*,*] = $#a,  #c[1,*] = $#b[*,0],  $#c[2,*] = $#b[*,1],  $#c[3,*] = $#a
</pre>


=====Usage:=====
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
 
<code>vsubn(<var>x</var>,<var>o</var>,<var>n</var>)</code>
 
=====Parameters:=====
 
;<var>x</var>
 
:The input vector or array.
 
;<var>o</var>
 
:The offset (an integer).
 
;<var>n</var>
 
:The number of values to extract.
 
=====Result:=====
 
The result is a scalar or a vector with the selected elements from <var>x</var>.

Revision as of 08:55, 6 April 2011

Extract rows from a vector or matrix.

Usage
vsubn(x {, o {, n}})
x
source vector or matrix
o
offset, 0 <= o < nrow(x)
n
length, n > 0 and o+n <= nrow(x)
Result
A matrix with nrow(x1) columns. The columns of the arguments are merged from left to right into the rows of the result matrix. Note: vmrow(a,b,c) returns the same result as trn(vmcol(a,b,c)), but vmrow is faster and uses less memory than the nested command.
See also
vv, vvget, vvset, vvcat, vmcol, vsubn, vsubc

Example:

#a := eval vv(1,2,3,4,5)
#b := eval init(5,2,0)
#c := eval vmcol($#a, $#b, $#a) 
// -> $#c is a matrix with 4 rows and 5 columns:
//    $#c[*,*] = $#a,  #c[1,*] = $#b[*,0],  $#c[2,*] = $#b[*,1],  $#c[3,*] = $#a

<function list>

Navigation menu

Personal tools