Complex (function): Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "{{APL built-ins}}" to "{{APL built-ins}}Category:Primitive functions")
Line 17: Line 17:
== References ==
== References ==
<references/>
<references/>
{{APL built-ins}}[[Category:Primitive functions]]
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]]

Revision as of 10:13, 4 May 2020

Complex () is a dyadic scalar function which combines its arguments into a complex number having with the left argument as real part and the right argument as imaginary part. It was added to J as j. together with initial support for complex numbers, and was adopted in Extended Dyalog APL using the glyph because it was seen as a type of numerical composition () for the circular () domain. Complex shares its glyph with Imaginary which is equivalent to applying Complex with a left argument of 0.

The question of whether to include this function is one of Roger Hui's 50 exercises in APL language design[1]:

Complex numbers can be constructed as ordered pairs of real numbers, similar to how integers can be constructed as ordered pairs of natural numbers and rational numbers as ordered pairs of integers. For complex numbers, j. plays the same role as - for integers and ÷ for rational numbers.

Examples

Try it online!

      ¯2 9 5 ⌾ 3 ¯4 6
¯2J3 9J¯4 5J6

Documentation

References

  1. Roger Hui. Some Exercises in APL Language Design. Jsoftware. 2016.
APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector