Programmer Guide/Command Reference/EVAL/vvset: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
m (1 revision: Initial import) |
No edit summary |
||
Line 10: | Line 10: | ||
|Create a copy of the vector x and replace the elements <var>o</var>+i*<var>d</var> (i = 0..nrow(<var>y</var>)-1) with the values <var>y</var>[i] | |Create a copy of the vector x and replace the elements <var>o</var>+i*<var>d</var> (i = 0..nrow(<var>y</var>)-1) with the values <var>y</var>[i] | ||
|} | |} | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | |||
Create a copy of the vector ''x'' and replace elements. | |||
---- | |||
;Usage 1: '''<code>vvset(<var>x</var> , <var>y</var> {, <var>o</var> {, <var>d</var>, <var>n</var>}}})</code>''' | |||
:;<var>x</var>: source vector | |||
:;<var>y</var>: replace value | |||
:;<var>o</var>: starting index, 0 <= o < <code>nrow(''x'')</code> (default=0) | |||
:;<var>d</var>: index increment (default=1) | |||
:;<var>n</var>: number of values to replace (default=<code>nrow(''x'')</code>) | |||
;Result 1: The result ''r'' is copy of the vector ''x''. All elements ''r''[''o''+''i''*''d''] (''i'' = 0..''n''-1) are replaced by the value ''y''. | |||
---- | |||
;Usage 2: '''<code>vvset(<var>x</var> , <var>y</var> {, <var>o</var> {, <var>d</var>}})</code>''' | |||
:;<var>x</var>: source vector | |||
:;<var>y</var>: replace vector | |||
:;<var>o</var>: starting index, 0 <= o < <code>nrow(''x'')</code> (default=0) | |||
:;<var>d</var>: index increment (default=1) | |||
;Result 1: The result ''r'' is copy of the vector ''x''. All elements ''r''[''o''+''i''*''d''] (''i'' = 0..nrow(''y'')-1) are replaced by the value ''y''[''i'']. | |||
---- | |||
The function failes if an index value is out of bounds. | |||
;See also: [[Programmer_Guide/Command_Reference/EVAL/vv|vv]], [[Programmer_Guide/Command_Reference/EVAL/vvget|vvget]], [[Programmer_Guide/Command_Reference/EVAL/vvcat|vvcat]], [[Programmer_Guide/Command_Reference/EVAL/vmcol|vmcol]], [[Programmer_Guide/Command_Reference/EVAL/vmrow|vmrow]], [[Programmer_Guide/Command_Reference/EVAL/vsubn|vsubn]], [[Programmer_Guide/Command_Reference/EVAL/vsubc|vsubc]] | |||
Example: | |||
<pre> | |||
#a := eval vv(1,2,4,8,16,32) | |||
#b := eval vvget($#a, 0, 2, 3) | |||
// -> #b = { 1 , 4 , 16 } | |||
#c := eval vvget($#a, 5, -1, 4) | |||
// -> #c = { 32, 16, 8, 4 } | |||
</pre> | |||
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] |
Revision as of 07:51, 6 April 2011
vvset
vvset(x, yS, o, d, n) | Create a copy of the vector x and replace the elements o+i*d (i = 0..n-1) with the value ys. |
vvset(x, y, o, d) | Create a copy of the vector x and replace the elements o+i*d (i = 0..nrow(y)-1) with the values y[i] |
Create a copy of the vector x and replace elements.
- Usage 1
vvset(x , y {, o {, d, n}}})
- x
- source vector
- y
- replace value
- o
- starting index, 0 <= o <
nrow(x)
(default=0) - d
- index increment (default=1)
- n
- number of values to replace (default=
nrow(x)
)
- Result 1
- The result r is copy of the vector x. All elements r[o+i*d] (i = 0..n-1) are replaced by the value y.
- Usage 2
vvset(x , y {, o {, d}})
- x
- source vector
- y
- replace vector
- o
- starting index, 0 <= o <
nrow(x)
(default=0) - d
- index increment (default=1)
- Result 1
- The result r is copy of the vector x. All elements r[o+i*d] (i = 0..nrow(y)-1) are replaced by the value y[i].
The function failes if an index value is out of bounds.
Example:
#a := eval vv(1,2,4,8,16,32) #b := eval vvget($#a, 0, 2, 3) // -> #b = { 1 , 4 , 16 } #c := eval vvget($#a, 5, -1, 4) // -> #c = { 32, 16, 8, 4 }