📄 mf_dsign.hlp
字号:
{smcl}
{* 15mar2004}{...}
{cmd:help mata dsign()}
{hline}
{* index dsign()}{...}
{* index FORTRAN}{...}
{* index sign()}{...}
{title:Title}
{p 4 4 2}
{bf:[M-5] design() -- FORTRAN-like DSIGN() function}
{title:Syntax}
{p 8 12 2}
{it:real scalar}
{cmd:dsign(}{it:real scalar a}{cmd:,}
{it:real scalar b}{cmd:)}
{title:Description}
{p 4 4 2}
{cmd:dsign(}{it:a}{cmd:,} {it:b}{cmd:)} returns {it:a} with the sign of
{it:b}, defined as abs({it:a}) if {it:b}>=0 and -abs({it:a}) otherwise.
{p 4 4 2}
This function is useful when translating FORTRAN programs.
{p 4 4 2}
Note that the in-line construction
{cmd:(}{it:b}{cmd:>=0 ? abs(}{it:a}{cmd:) : -abs(}{it:a}{cmd:))}
{p 4 4 2}
is clearer. Also, differentiate carefully between what {cmd:dsign()}
returns (equivalent to the above construction) and
{cmd:signum(}{it:b}{cmd:)}*{cmd:abs(}{it:a}{cmd:)}, which is almost
equivalent but returns 0 when {it:b} is 0 rather than
{cmd:abs(}{it:a}{cmd:)}. (Message: {cmd:dsign()} is not one of our
favorite functions.)
{title:Conformability}
{cmd:dsign(}{it:a}{cmd:,} {it:b}{cmd:)}:
{it:a}: 1 {it:x} 1
{it:b}: 1 {it:x} 1
{it:result}: 1 {it:x} 1
{title:Diagnostics}
{p 4 4 2}
{cmd:dsign(.,} {it:b}{cmd:)} returns {cmd:.} for all {it:b}.
{p 4 4 2}
{cmd:dsign(}{it:a}{cmd:, .)} returns abs({it:a}) for all {it:a}.
{title:Source code}
{p 4 4 2}
{view dsign.mata, adopath asis:dsign.mata}
{title:Also see}
{p 4 13 2}
Manual: {hi:[M-5] dsign()}
{p 4 13 2}
Online: help for
{bf:{help mf_sign:[M-5] sign()}};
{bf:{help m4_scalar:[M-4] scalar}}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -