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

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
Create a copy of the vector ''x'' and replace elements.
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>'''
;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>x</var>: source vector
:;<var>y</var>: replace value (scalar)
:;<var>y</var>: replace value (scalar)
:;<var>o</var>: starting index, 0 <= o < <code>nrow(''x'')</code> (default=0)
:;<var>o</var>: starting index, 0 &le; o < <code>nrow(''x'')</code> (default=0)
:;<var>d</var>: index increment (default=1)
:;<var>d</var>: index increment (default=1)
:;<var>n</var>: number of values to replace (default=<code>nrow(''x'')</code>)
:;<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 <code>''r''[''o''+''i''*''d'']</code> (with: <code>''i'' = 0..''n''-1</code>) are replaced by the value <code>''y''</code>.
;Result 1: The result ''r'' is copy of the vector ''x''. All elements <code>''r''[''o''+''i''*''d'']</code> (with: <code>''i'' = 0..''n''-1</code>) are replaced by the value <code>''y''</code>.
----
----
;Usage 2: '''<code>vvset(<var>x</var> , <var>y</var> {, <var>o</var> {, <var>d</var>}})</code>'''
;Usage 2: <code>vvset(<var>x</var> , <var>y</var> {, <var>o</var> {, <var>d</var>}})</code>
:;<var>x</var>: source vector
:;<var>x</var>: source vector
:;<var>y</var>: replace vector
:;<var>y</var>: replace vector
:;<var>o</var>: starting index, 0 <= o < <code>nrow(''x'')</code> (default=0)
:;<var>o</var>: starting index, 0 &le; o < <code>nrow(''x'')</code> (default=0)
:;<var>d</var>: index increment (default=1)
:;<var>d</var>: index increment (default=1)
;Result 2: The result ''r'' is copy of the vector ''x''. All elements <code>''r''[''o''+''i''*''d'']</code> (with: <code>''i'' = 0..nrow(''y'')-1</code>) are replaced by the value <code>''y''[''i'']</code>.
;Result 2: The result ''r'' is copy of the vector ''x''. All elements <code>''r''[''o''+''i''*''d'']</code> (with: <code>''i'' = 0..nrow(''y'')-1</code>) are replaced by the value <code>''y''[''i'']</code>.
----
----
The function failes if an index value is out of bounds.
The function fails if an index value is out of bounds.
;See also: [[../vv|vv]], [[../vvget|vvget]], [[../vvcat|vvcat]], [[../vmcol|vmcol]], [[../vmrow|vmrow]], [[../vsubn|vsubn]], [[../vsubc|vsubc]]
 
[[../#Functions|<function list>]]


;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:
Example:
<pre>
#a := eval fill(10,0,1)
#a := eval fill(10,0,1)
#b := eval vvset($#a, -1, 1, 2, 5)  
#b := eval vvset($#a, -1, 1, 2, 5)  
// &rarr; #b = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 , -1 }
// -> #b = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 , -1 }
#c := eval vvset($#b, fill(4, 9, -3), 6, 1)
#c := eval vvset($#b, fill(4, 9, -3), 6, 1)
// &rarr; #c = { 0 , -1 , 2 , -1 , 4 , -1 , 9 , 6 , 3 , 0 }
// -> #c = { 0 , -1 , 2 , -1 , 4 , -1 , 9 , 6 , 3 , 0 }
// reverse vector indeces
// reverse vector indeces
#arev := eval vvset($#a, $#a, $#a[]-1, -1)
#arev := eval vvset($#a, $#a, $#a[]-1, -1)
// &rarr; #arev = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 }
// -> #arev = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 }
</pre>
 
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]

Latest revision as of 19:03, 21 April 2011

Create a copy of the vector x and replace elements.


Usage 1
vvset(x , y {, o {, d, n}}})
x
source vector
y
replace value (scalar)
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] (with: 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 2
The result r is copy of the vector x. All elements r[o+i*d] (with: i = 0..nrow(y)-1) are replaced by the value y[i].

The function fails if an index value is out of bounds.

See also
vv, vvget, vvcat, vmcol, vmrow, vsubn, vsubc

<function list>


Example:

#a := eval fill(10,0,1)
#b := eval vvset($#a, -1, 1, 2, 5) 
// → #b = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 , -1 }
#c := eval vvset($#b, fill(4, 9, -3), 6, 1)
// → #c = { 0 , -1 , 2 , -1 , 4 , -1 , 9 , 6 , 3 , 0 }
// reverse vector indeces
#arev := eval vvset($#a, $#a, $#a[]-1, -1)
// → #arev = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 }

Navigation menu

Personal tools