⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mf_swap.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
字号:
{smcl}
{* 28mar2005}{...}
{cmd:help mata swap()}
{hline}
{* index swap()}{...}

{title:Title}

{p 4 8 2}
{bf:[M-5] swap() -- Interchange contents of variables}


{title:Syntax}

{p 8 8 2}
{it:void}
{cmd:swap(}{it:transmorphic matrix A}{cmd:,}
{it:transmorphic matrix B}{cmd:)}


{title:Description}

{p 4 4 2}
{cmd:swap(}{it:A}{cmd:,} {it:B}{cmd:)} 
interchanges the contents of {it:A} and {it:B}.  {it:A} and {it:B} 
are not required to be of the same type or dimension.


{title:Remarks}

{p 4 4 2}
There is no faster way than {cmd:swap(}{it:A}{cmd:,} {it:B}{cmd:)} to assign
{it:A}{cmd:=}{it:B} when you do not care about the contents of {it:B} after the
assignment.  For instance, you have the code

		{it:A} {cmd:=} {it:B}
		{it:B} {cmd:=} ...{it:(matrix expression)}...

{p 4 4 2}
Faster is

		{cmd:swap(}{it:A}{cmd:,} {it:B}{cmd:)} 
		{it:B} {cmd:=} ...{it:(matrix expression)}...

{p 4 4 2}
The execution time of {cmd:swap()} is independent of the size of {it:A} and
{it:B}, and {cmd:swap()} conserves memory to boot.  Pretend {it:B} is a 900
{it:x} 900 matrix.  After executing {it:A}{cmd:=}{it:B}, but before {it:B} is
reassigned, two copies of the 900 {it:x} 900 matrix exist.  That does not 
happen with {cmd:swap()}.



{title:Conformability}

    {cmd:swap(}{it:A}{cmd:,} {it:B}{cmd:)}:
	{it:input:}
		{it:A}:  {it:r1 x c1}
		{it:B}:  {it:r2 x c2}
	{it:output}
		{it:A}:  {it:r2 x c2}
		{it:B}:  {it:r1 x c1}


{title:Diagnostics}

{p 4 4 2}
{cmd:swap(}{it:A}{cmd:,} {it:B}{cmd:)} works only with variables.  Do not
code, for instance, {cmd:swap(}{it:A}{cmd:[}{it:i}{cmd:,}{it:j}{cmd:],}
{it:A}{cmd:[}{it:j}{cmd:,}{it:i}{cmd:])}.  It is not an error, but
it will have no effect.


{title:Source code}

{p 4 4 2}
Function is built-in.


{title:Also see}

{p 4 13 2}
Manual:  {hi:[M-5] swap()}

{p 4 13 2}
Online:  help for 
{bf:{help m4_programming:[M-4] programming}}
{p_end}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -