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

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====vvset=====
{|
|-
|vvset(x, <var>y</var>S, <var>o</var>, <var>d</var>, <var>n</var>)
|Create a copy of the vector x and replace the elements <var>o</var>+i*<var>d</var> (i = 0..<var>n</var>-1) with the value <var>y</var>s.
|-
|vvset(x, <var>y</var>, <var>o</var>, <var>d</var>)
|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}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
Create a copy of the vector ''x'' and replace elements.
Create a copy of the vector ''x'' and replace elements.
Line 27: Line 15:
:;<var>o</var>: starting index, 0 <= o < <code>nrow(''x'')</code> (default=0)
:;<var>o</var>: starting index, 0 <= o < <code>nrow(''x'')</code> (default=0)
:;<var>d</var>: index increment (default=1)
:;<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''].
;Result 2: 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.
The function failes if an index value is out of bounds.
Line 35: Line 23:
Example:
Example:
<pre>
<pre>
#a := eval vv(1,2,4,8,16,32)
#a := eval fill(10,0,1)
#b := eval vvget($#a, 0, 2, 3)  
#b := eval vvset($#a, -1, 1, 2, 5)  
// -> #b = { 1 , 4 , 16 }
// -> #b = { 0 , -1 , 2 , -1 , 4 , -1 , 6 , -1 , 8 , -1 }
#c := eval vvget($#a, 5, -1, 4)
#c := eval vvset($#b, fill(4, 9, -3), 6, 1)
// -> #c = { 32, 16, 8, 4 }
// -> #c = { 0 , -1 , 2 , -1 , 4 , -1 , 9 , 6 , 3 , 0 }
</pre>
</pre>


[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]

Revision as of 07:56, 6 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
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 2
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
vv, vvget, vvcat, vmcol, vmrow, vsubn, vsubc

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 }

<function list>

Navigation menu

Personal tools