Difference between revisions of "Signum"

From APL Wiki
Jump to navigation Jump to search
Line 1: Line 1:
{{Built-in|Signum|×}}, '''Sign''', '''Sign of''', or '''Direction''' is a [[monadic]] [[primitive function]] which returns the [[wikipedia:Sign function|sign]] of a real or [[complex]] number. That is, it returns 0 when given an argument of 0, and otherwise returns a number with [[magnitude]] 1 given by [[Divide|dividing]] the argument by its own magnitude.
+
{{Built-in|Signum|×}}, '''Sign''', '''Sign of''', or '''Direction''' is a [[monadic]] [[scalar function]] which returns the [[wikipedia:Sign function|sign]] of a real or [[complex]] number. That is, it returns 0 when given an argument of 0, and otherwise returns a number with [[magnitude]] 1 given by [[Divide|dividing]] the argument by its own magnitude.
  
 
== Examples ==
 
== Examples ==

Revision as of 23:40, 28 May 2020

×

Signum (×), Sign, Sign of, or Direction is a monadic scalar function which returns the sign of a real or complex number. That is, it returns 0 when given an argument of 0, and otherwise returns a number with magnitude 1 given by dividing the argument by its own magnitude.

Examples

The three possible results of Signum on a real argument are 0, 1, and ¯1.

      × ¯3 0 5
¯1 0 1

In dialects with complex numbers, Signum is a somewhat more complicated function, and may return any unit complex number.

      × 3j4
0.6J0.8

The result is still equal to the original number divided by its magnitude:

      | 3j4
5
      3j4 ÷ | 3j4
0.6J0.8

The magnitude of the result for a non-zero argument is always 1.

      | × 3j4 ¯2j1 6j¯7
1 1 1

Zero divided by zero

The identity ×z z÷|z holds only when z is not zero in most APLs. In "Zero Divided by Zero"[1], Eugene McDonnell gave this identity as a reason to define 0÷0 to be equal to 0. In J, which took McDonnell's suggestion, the identity always holds. Dyalog APL and NARS2000 allow the choosing division method though the default remains 1.

External links

Documentation

References

APL built-ins [edit]
Primitive functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Case convertUnicode convert
Operators SearchReplace