Example CpxVector new 015




These examples show how to construct a CpxVector. A Vector with #void values is also constructed using the new function.



Creates a new Cpx Vector containing 2 Character values.

(setq X (new Vector: complex: 2 1.0)) Returns: #<CpxVector 123456>

Displays the contents of the Complex Vector.

(display X) Returns: #(cpx| #c1.0+0.0i #c1.0+0.0i )

Creates a new Cpx Vector with no values.

(setq X (new Vector: complex: 0 1.0 2.0)) Returns: #<CpxVector 234567>

Displays the contents of the Cpx Vector.

(display X) Returns: #(cpx| )

Create a new Cpx Vector, with no value but with a set cdr value.

(setq X (new Vector: complex: q . #c5.0+6.0i )) Returns: #<CpxVector 345678>

Displays the contents of the CpxVector.

(display X) Returns: #(cpx| . #c5.0+6.0i)

Notes and Hints

If a reference to an existing object is modified to point to a new object (as shown in the above examples), the reference count on the previous object on the heap will be decremented. If the count goes to zero, the object's allocated memory area will automatically be reclaimed by the garbage collector.

If the returned value from new or make new is not captured, (e.g. using setq), then the newly created heap object will not have any reference to it and, thus, will soon be swept away by the garbage collector.

The space required to hold the complex number data (not including headers, etc.) is twice the size of a double. Internally, the real part of each complex number is stored as the first double and the imaginary part is stored as the second double.


Related Examples

Here are examples of the new function at work.

BitVector new 013 Brick new 015 ByteVector new 015 CpxVector new 015
Dictionary new 004 Directory new 005 Directory new 006 FltVector new 009
IntVector new 010 Matrix new 009 Matrix new 010 NumMatrix new 015
NumVector new 011 ObjVector new 012 ObjectRepository new 014 PcodeVector new 014
ShortVector new 011 String new 001 Structure new 003 Symbol new 002
Vector new 007 Vector new 008


Function Links

Here is the link to the current function used in this example.


Here are a number of links to other related functions.

setq(CpxVector) define(CpxVector)


Argument Types

Here are the links to the data types of the arguments used in this example.


Here are a number of links to examples having similar argument types.

CpxVector addMethod 028 CpxVector append 013 CpxVector avg 002 CpxVector binaryInsert 008
CpxVector binarySearch 008 CpxVector cdr 011 CpxVector compare 020 CpxVector compareEQ 020
CpxVector compareGE 020 CpxVector compareGT 020 CpxVector compareLE 020 CpxVector compareLT 020
CpxVector compareNE 020 CpxVector copy 013 CpxVector new 015 CpxVector send 028

How do I contact the AIS Server team?

You can always talk with the AIS at aiserver.sourceforge.net.