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

From STX Wiki
Jump to navigationJump to search
(Created page with '{{DISPLAYTITLE:{{SUBPAGENAME}}}} Compute the next power of 2. ;Usage: '''npow2(<var>x</var>)</code>''' :;<var>x</var>: a scalar, vector or matrix ;Result: If ''x'' is a scalar, t…')
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
Compute the next power of 2.
Compute the next power of 2.
;Usage: '''npow2(<var>x</var>)</code>'''
;Usage: '''<code>npow2(<var>x</var>)</code>'''
:;<var>x</var>: a scalar, vector or matrix
:;<var>x</var>: a scalar, vector or matrix
;Result: If ''x'' is a scalar, the result ''r'' is the integer number ''N'', which is the smallest value with <code>''N''=2<sup>''M''</sup></code> (''M'' is an integer greater/equal 0) and ''N''>=''x''.  
;Result: If ''x'' is a scalar, the result is the integer number N, which is the smallest value with <code>N=2<sup>M</sup></code> (M is an integer greater/equal 0) and N&ge;''x''.  
:If ''x'' is a vector or a matrix, the function returns <code>npow2(nrow(''x''))</code>.  
:If ''x'' is a vector or a matrix, the function returns <code>npow2(nrow(''x''))</code>.  
;See also: [[Programmer_Guide/Command_Reference/EVAL/fft|fft]], [[Programmer_Guide/Command_Reference/EVAL/ifft|ifft]]
;See also: [[../fft|fft]], [[../ifft|ifft]], [[Programmer Guide/Command Reference/INT|command INT]], [[Programmer Guide/Command Reference/NUM|command NUM]]
 
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
 


Example:
Example:
<pre>
#n := eval npow2(1000)
#n := eval npow2(1000)
// #n = 1024 = 2^10
// #n = 1024 = 2^10
</pre>
 
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]

Latest revision as of 20:12, 21 April 2011

Compute the next power of 2.

Usage
npow2(x)
x
a scalar, vector or matrix
Result
If x is a scalar, the result is the integer number N, which is the smallest value with N=2M (M is an integer greater/equal 0) and N≥x.
If x is a vector or a matrix, the function returns npow2(nrow(x)).
See also
fft, ifft, command INT, command NUM

<function list>


Example:

#n := eval npow2(1000)
// #n = 1024 = 2^10

Navigation menu

Personal tools