|
Complex Library / Reference |
|
Omikron Basic on the Internet: http://www.berkhan.com |
|
|
| This chapter features a description of all functions and procedures of the Library. Time and space is too limited, of course, to explain the theoretical background of each procedure at this time. You do have to know your way around the theory of complex numbers in order to make practical use of the Library. |
| Cinit | |
| Call this procedure once at the beginning of your program. The Complex Library may not be used prior
to the call. Important: This procedure changes the DATA pointer. So, if you want to read your own DATA after calling Cinit you previously have to restore the DATA pointer to the desired DATA. |
| Cexit | |
| Call this procedure once at the end of your program. The Complex Library may not be used subsequently. |
| Complex | |
| Only displays a copyright notice of the Complex Library. |
| FN Cmplx$(Real#,Imag#) | |
| Real# | REAL of complex number. |
| Imag# | IMAG of complex number. |
| The function returns a string, which represents the complex number. | |
| FN Re#(Z$) | |
| Z$ | Complex number. |
| The function returns the REAL of the complex number Z$ as a real number. | |
| FN Im#(Z$) | |
| Z$ | Complex number. |
| The function returns the IMAG of the complex number Z$ as a real number. | |
| Example: PRINT "The IMAG of the number is: ";FN Im#(Z$) |
| FN Re$(Z$) | |
| Z$ | Complex number. |
| The function returns the REAL of the complex number Z$ as a complex number. | |
| FN Im$(Z$) | |
| Z$ | Complex number. |
| The function returns the IMAG of the complex number Z$ as a complex number. | |
| Cinput(T$,R Z$) | |
| T$ | This string is initially displayed on the screen. If T$ is empty, then the query is performed with "x+iy=? ". |
| Z$ | After the return, this contains the entered complex number. |
| This procedure serves the input of complex numbers on the screen. Two real numbers, separated by commas, are expected: first the REAL, then the IMAG. The input has to be concluded with [Return]. | |
| Cread(R Z$) | |
| Z$ | After the return, this contains the read in complex number. |
| This procedure serves to read in complex numbers from DATA lines. The complex numbers have to be posted in the DATA lines as two floating point numbers each (REAL, IMAG). | |
| Example: The number 0.3,0.7i is supposed to be read in from DATA lines: Cinit RESTORE Cdata Cread A$ ' 'Here, A$ is processed by your program. ' INPUT "End with [Return]";Dummy Cexit END -Cdata DATA 0.3,0.7 |
| Cmat_Read(&A$(,),M,N) | |
| A$(0:M,0:N) | The complex numbers are read into this field. |
| M | Dimension of rows. |
| N | Dimension of columns. |
| This procedure reads in a whole matrix with the dimensions (M,N) from DATA lines. The complex numbers
have to be posted in the DATA lines as two floating point numbers each (REAL, IMAG). First, all elements of line zero are read in, then the elements of the first line, and so forth. |
|
| Example: The matrix Demo$(2,1) is supposed to be read in: Cinit RESTORE Demo_Data DIM Demo$(1,2) Cmat_Read &Demo$(,),1,2 ' 'Here, the Demo$(,) is being processed by your 'program. ' INPUT "End with [Return]";Dummy Cexit END -Demo_Data DATA 3,7,1,-1,5,6.7:'Elements of line zero. DATA 1.3,2,-7.3,4,5,6:'Elements of first line. |
| Cpoly_Read(&A$(),N) | |
| A$(0:N) | The complex polynomial coefficients are read into this field. |
| N | Degree of polynomial (highest power). |
| This field serves to read in the coefficients of a complex polynomial. The degree of the polynomial (highest power) is indicated with the parameter N. First, the coefficient for Z^0 is read in, then the one for Z^1, and so forth. The DATA pointer has to be set to the desired data first, of course. | |
| Example: An example can be found with Cpoly_Add. |
| Cinput_File(Handle,R Z$) | |
| Handle | That is the logical file number indicated with OPEN (1 to 16). |
| Z$ | After the return, this contains the read in complex number. |
| This procedure may be used to read a complex number from a file previously opened with OPEN "I". The number has to be first saved with Cwrite_File. | |
| Example: Loads 10 complex numbers into the field C$(0:9). The file "Complex.DAT" has to have been created first, of course: Cinit DIM C$(9) OPEN "I",3,FN Get_Fsspec$(0,0,"Complex.DAT") FOR I=0 TO 9 Cinput_File 3,C$(I) NEXT I ' 'Here, Demo$(,) is being processed by your program. CLOSE 3 INPUT "End with [Return]";Dummy Cexit END |
| 2.4 Output Functions | |||||||||
|
|||||||||
| Example: The example shows how to save a number with the Complex Library using Z$, and then how to input it again using Cinput_File: Cinit OPEN "O",1,FN Get_Fsspec$(0,0,"Demo.DAT") Z$=FN Cmplx$(5.5,-3.14) Cwrite_File 1,Z$ CLOSE 1 OPEN "I",1,FN Get_Fsspec$(0,0,"Demo.DAT") Cinput_File 1,X$ Cprint X$ CLOSE 1 INPUT "End with [Return]";Dummy Cexit END |
| Cprint(Z$) | |
| Z$ | Has to contain the complex number, which is supposed to be output. |
| This procedure provides an unformatted output of a complex number in the form of "Re+iIm". After the output, the write pointer is located at the beginning of the next line. | |
| Cprint_(Z$) | |
| Z$ | Has to contain the complex number, which is supposed to be output. |
| This procedure provides an unformatted output of a complex number in the form of "Re+iIm". After the output, the write pointer is located directly behind the output number. | |
| Cprint(T$,Z$) | |
| T$ | This variable may be used to pass text, which is output before the complex number. |
| Z$ | Has to contain the complex number, which is supposed to be output. |
| This procedure provides an unformatted output of a complex number in the form of "Re+iIm" with preceding text. After the output, the write pointer is located at the beginning of the next line. | |
| Cprint_(T$,Z$) | |
| T$ | This variable may be used to pass text, which is output before the complex number. |
| Z$ | Has to contain the complex number, which is supposed to be output. |
| This procedure provides an unformatted output of a complex number in the form of "Re+iIm" with preceding text. After the output, the write pointer is located directly behind the output number. | |
| Cprint_Using(F$,Z$) | |
| F$ | This variable may be used to pass a format string as in PRINT USING, which is then used for the formatting of the complex number. |
| Z$ | Has to contain the complex number, which is supposed to be output. |
| This procedure provides a formatted output of a complex number. After the output, the write pointer is located at the beginning of the next line. | |
| Cprint_Using_(F$,Z$) | |
| F$ | This variable may be used to pass a format string as in PRINT USING, which is then used for the formatting of the complex number. |
| Z$ | Has to contain the complex number, which is supposed to be output. |
| This procedure provides a formatted output of a complex number. After the output, the write pointer is located directly behind the output number. | |
| Cprint_Using(T$,F$,Z$) | |
| T$ | This variable may be used to pass a text, which is output before the complex number. |
| F$ | This variable may be used to pass a format string as in PRINT USING, which is then used for the formatting of the complex number. |
| Z$ | Has to contain the complex number, which is supposed to be output. |
| This procedure provides a formatted output of a complex number with preceding text. After the output, the write pointer is located at the beginning of the next line. | |
| Cprint_Using_(T$,F$,Z$) | |
| T$ | This variable may be used to pass a text, which is output before the complex number. |
| F$ | This variable may be used to pass a format string as in PRINT USING, which is then used for the formatting of the complex number. |
| Z$ | Has to contain the complex number, which is supposed to be output. |
| This procedure provides a formatted output of a complex number with preceding text. After the output, the write pointer is located directly behind the output number. | |
| Cmat_Print_Using(F$,&A$(,),M,N) | |
| F$ | This variable may be used to pass a format string as in PRINT USING, which is then used for the formatting of the complex number. |
| A$(0:M,0:N) | This field has to contain the complex elements of the matrix, which is supposed to be output. |
| M | Dimension of the rows. |
| N | Dimension of the columns. |
| This procedure provides a formatted output of a matrix consisting of complex numbers. After the output, the write pointer is located at the beginning of the next line. | |
| Cpoly_Print_Using(F$,&A$(),N) | |
| F$ | This variable may be used to pass a format string as in PRINT USING, which is then used for the formatting of the complex number. |
| A$(0:N) | This field has to contain the complex coefficients of the polynomial, which is supposed to be output. |
| N | Degree of polynomial (highest power). |
| This procedure provides a formatted output of a complex polynomial. After the output, the write pointer is located at the beginning of the next line. | |
| 2.5 Basic Arithmetic Operations | ||||||||
|
||||||||
| FN Csub$(Z1$,Z2$) | |
| Z1$ | Complex number. |
| Z2$ | Complex number. |
| The function returns the difference of the two numbers (Z1$-Z2$). | |
| FN Cmul$(Z1$,Z2$) | |
| Z1$ | Complex number. |
| Z2$ | Complex number. |
| The function returns the product of the two numbers (Z1$*Z2$). | |
| FN Cdiv$(Z1$,Z2$) | |
| Z1$ | Complex number. |
| Z2$ | Complex number. |
| The function returns the quotient of the two numbers (Z1$/Z2$). | |
| FN Rmul$(Re#,Z$) | |
| Re# | Real number. |
| Z$ | Complex number. |
| The function returns the product of the two numbers (Re#*Z$). | |
| FN Rdiv$(Z$,Re#) | |
| Z$ | Complex number. |
| Re# | Real number. |
| The function returns the quotient of the two numbers (Z$/R#). | |
| FN Imul$(Im#,Z$) | |
| Im# | Imaginary number. |
| Z$ | Complex number. |
| The function returns the product of the two numbers (Im#*Z$). | |
| FN Idiv$(Z$,Im#) | |
| Z$ | Complex number. |
| Im# | Imaginary number. |
| The function returns the quotient of the two numbers (Z$/Im#). | |
| FN Cmul_I$(Z$) | |
| Z$ | Complex number. |
| The function returns the product of the complex number and i (i*Z$). | |
| FN Cdiv_I$(Z$) | |
| Z$ | Complex number. |
| The function returns the quotient from the complex number and i (Z$/i). | |
| FN Cch_S$(Z$) | |
| Z$ | Complex number. |
| The function returns the negative value of the complex number (-Z$). | |
| FN Cconj$(Z$) | |
| Z$ | Complex number. |
| The function returns the complex-conjugated value of the complex number. | |
| FN Cabs$(Z$) | |
| Z$ | Complex number. |
| The function calculates the amount of the complex number (SQR(Re^2+Im^2)). The result is returned as a complex number. | |
| FN Cabs#(Z$) | |
| Z$ | Complex number. |
| The function calculates the amount of the complex number (SQR(Re^2+Im^2)). The result is returned as a real number. | |
| FN Cabs_Sqrd$(Z$) | |
| Z$ | Complex number. |
| The function calculates the square of the amount of the complex number (Re^2+Im^2). The result is returned as a complex number. This function is a bit faster than FN Cabs$(Z$). | |
| FN Cabs_Sqrd#(Z$) | |
| Z$ | Complex number. |
| The function calculates the square of the amount of the complex number (Re^2+Im^2). The result is returned as a real number. This function is a bit faster than FN Cabs#(Z$). | |
| Cart_To_Polar(Z$,R A#,R P#) | |
| Z$ | Complex number. |
| A# | Absolute amount of the complex number Z$ (distance from point of origin). |
| P# | Phase of the complex number Z$ (angle with the real axis). |
| The procedure calculates amount and phase of the complex number Z$. The value of the phase is dependent on the set angle mode (DEG and/or RAD). | |
| FN Polar_To_Cart$(A#,P#). | |
| A# | Absolute amount of a complex number (distance from point of origin). |
| P# | Phase of a complex number (angle with real axis). |
| If you pass the spherical coordinates of a complex number to this function, the number will be returned in the form of a string. | |
| 2.7 Transcendental Functions Interval limits have been indicated with a few of the following functions. In that case, for example, [100,200] signifies the interval that encompasses the points 100 and 200, and [100,200[ signifies the inclusion of 100 but the exclusion of 200. |
| A few of the functions (such as the logarithm) appear twice. This is due to the fact that these
functions can only be unambiguously defined by a section in the complex plane. Different choices are available
when choosing this section; in the beginning, one chooses the section so that the complex function, in the form
of the maximum analytical continuation, is the result of the corresponding real function. The section defined in
such a way has been assigned the default name in the Complex Library, which the real function possesses as well.
If a different section has been chosen, this can be recognized by the extension "_P" behind the procedure or function name. "_P" is meant to point towards the section [0,INF] (positive). Most users will usually choose the main branches, that is the names without extension. The definition of the functions in the sections, however, is a question of conventions and the implementations in the Complex Library may therefore be different from implementations on other systems. |
| FN Cexp$(Z$) | |
| Z$ | Complex number. |
| Exponential function with complex argument for base number e. | |
| FN Iexp$(Im#) | |
| Im# | Imaginary number. |
| Exponential function with purely imaginary argument for base number e. | |
| FN Rexp$(Re#) | |
| Re# | Real number. |
| Exponential function with purely real argument for base number e. | |
| FN Csin$(Z$) | |
| Z$ | Complex number. |
| Sine with complex argument. | |
| FN Ccos$(Z$) | |
| Z$ | Complex number. |
| Cosine with complex argument. | |
| FN Ctan$(Z$) | |
| Z$ | Complex number. |
| Tangent with complex argument. | |
| FN Ccot$(Z$) | |
| Z$ | Complex number. |
| Cotangent with complex argument. | |
| FN Csec$(Z$) | |
| Z$ | Complex number. |
| Secant with complex argument. | |
| FN Ccosec$(Z$) | |
| Z$ | Complex number. |
| Cosecant with complex argument. | |
| FN Csinh$(Z$) | |
| Z$ | Complex number. |
| Hyperbolic sine with complex argument. | |
| FN Ccosh$(Z$) | |
| Z$ | Complex number. |
| Hyperbolic cosine with complex argument. | |
| FN Ctanh$(Z$) | |
| Z$ | Complex number. |
| Hyperbolic tangent with complex argument. | |
| FN Ccoth$(Z$) | |
| Z$ | Complex number. |
| Hyperbolic cotangent with complex argument. | |
| FN Csech$(Z$) | |
| Z$ | Complex number. |
| Hyperbolic secant with complex argument. | |
| FN Ccosech$(Z$) | |
| Z$ | Complex number. |
| Hyperbolic cosecant with complex argument. | |
| FN Cln$(Z$) | |
| Z$ | Complex number. |
| Main branch of natural logarithm with section [-INF,0]. | |
| FN Cln_P$(Z$) | |
| Z$ | Complex number. |
| Natural logarithm with section [0,+INF]. | |
| FN Casin$(Z$) | |
| Z$ | Complex number. |
| Arc sine with section [-INF,-1[ and ]1,+INF]. | |
| FN Cacos$(Z$) | |
| Z$ | Complex number. |
| Arc cosine with section [-INF,-1[ and ]1,+INF]. | |
| FN Catan$(Z$) | |
| Z$ | Complex number. |
| Arc tangent with section and [-INF*i,-i[ and ]i,INF*i]. | |
| FN Cacot$(Z$) | |
| Z$ | Complex number. |
| Arc cotangent with section [-i,i]. | |
| FN Casinh$(Z$) | |
| Z$ | Complex number. |
| Inverse hyperbolic sine with section [-INF*i,-i] and [i,INF*i]. | |
| FN Cacosh$(Z$) | |
| Z$ | Complex number. |
| Inverse hyperbolic cosine with section [-INF,1]. | |
| FN Catanh$(Z$) | |
| Z$ | Complex number. |
| Inverse hyperbolic tangent with section [-INF,-1] and [1,INF]. | |
| FN Cacoth$(Z$) | |
| Z$ | Complex number. |
| Inverse hyperbolic cotangent with section [-1,1]. | |
| FN Crecp$(Z$) | |
| Z$ | Complex number. |
| Reciprocal value (1/Z$). | |
| FN Crecp2$(Z$,A$) | |
| Z$ | Complex number. |
| A$ | Complex number by which the value Z$ is supposed to be shifted. |
| Shifted reciprocal value (1/(Z$-A$)). | |
| FN Csqr$(Z$) | |
| Z$ | Complex number. |
| The square root of the main branch, section [-INF,0]. | |
| FN Csqr_P$(Z$) | |
| Z$ | Complex number. |
| Square root, section [0,INF]. | |
| FN Csqrd$(Z$) | |
| Z$ | Complex number. |
| The square of the complex number Z$. | |
| FN Rpower$(Z$,E#) | |
| Z$ | Complex number. |
| E# | Real exponent. |
| Calculates Z$^E#. | |
| FN Cpower$(Z$,E$) | |
| Z$ | Complex number. |
| E$ | Complex exponent. |
| Calculates Z$^E$. | |
| FN C1_P_Sqrd$(Z$) | |
| Z$ | Complex number. |
| Calculates 1+Z$^2. | |
| FN C1_M_Sqrd$(Z$) | |
| Z$ | Complex number. |
| Calculates 1-Z$^2. | |
| FN Cm1_P_Sqrd$(Z$) | |
| Z$ | Complex number. |
| Calculates -1+Z$^2. | |
| FN Cm1_M_Sqrd$(Z$) | |
| Z$ | Complex number. |
| Calculates -1-Z$^2. | |
| FN C1_P_Sqrd$(Z$) | |
| Z$ | Complex number. |
| Calculates 1+Z$^2. | |
| Croots(Z$,&A$(),N) | |
| Z$ | Complex number. |
| A$(0:N) | The roots of the complex number Z$ are returned in this field. |
| N | Indicates the degree of the root calculation. |
| Calculates the (N+1)th root from Z$. Because a complex number has exactly N Nth roots, the procedure calculates the N values as well. These are returned in the string field A$(), which has to be dimensioned to no less than N-1. | |
| Example: Calculate the 3rd radicals from -7. Cinit DIM R$(2) Z$=FN Cmplx$(-7,0) Croots Z$,&R$(),2 Cprint R$(0):Cprint R$(1):Cprint R$(2) INPUT "End with [Return]";Dummy Cexit END |
| 2.8 Polynomial Functions |
| The Complex Library offers a variety of diverse functions, which simplify handling of polynomials with complex coefficients. Such a polynomial is completely determined by its coefficients, that is by a quantity of complex numbers (a vector). The Complex Library thus depicts a polynomial with a one-dimensional string array by the first element (e.g., Poly$(0)) representing the constant coefficient and Poly$(N) the coefficient of Z$^N. |
| Cpoly_Clear(&A$(),N) | |
| A$(0:N) | Complex coefficients of polynomial. |
| N | Degree of polynomial (highest power). |
| After the dimensioning, the elements of a string field contain empty strings (the empty strings do not represent complex zeros). This procedure sets the elements of the field A$(0:N) to complex zeros. | |
| Example: We want to work with a polynomial for which we have chosen the name Polynom$(). The maximum power in our polynomial is Z$^15. First, we want to create the polynomial and set it to zero: Cinit DIM Polynom$(15) Cpoly_Clear &Polynom$(),15 Cpoly_Print_Using "",&Polynom$(),15 INPUT "End with [Return]";Dummy Cexit END |
| Cpoly_Equal(&A$(),&C$(),N) | |
| A$(0:N) | Complex coefficients of the source polynomial. |
| C$(0:N) | Complex coefficients of the target polynomial. |
| N | Degree of polynomial (highest power). |
| This procedure assigns the polynomial A$(0:N) to the polynomial C$(0:N) and thus corresponds to the BASIC command C=A with the difference that, in this case, a whole polynomial is assigned and not only an individual number. | |
| Cpoly_Add(&A$(),&B$(),&C$(),M,N) | |
| A$(0:M) | Complex coefficients of the first addend. |
| B$(0:N) | Complex coefficients of the second addend. |
| C$(0:MAX(M,N)) | Complex coefficients of the sum polynomial. |
| M | Degree of polynomial A$() (highest power). |
| N | Degree of polynomial B$() (highest power). |
| This procedure adds the polynomial A$() to the polynomial B$() and returns the result in C$() (C$()=A$()+B$()). This is carried out through the addition of the coefficients with the same power. | |
| Example: Addition of the polynomials Poly1$(0:3) and Poly2$(0:8), with the result returned in Poly3$(). Cinit DIM Poly1$(3),Poly2$(8),Poly3$(8) RESTORE Polynomials Cpoly_Read &Poly1$(),3 Cpoly_Read &Poly2$(),8 Cpoly_Add &Poly1$(),&Poly2$(),&Poly3$(),3,8 Cpoly_Print_Using "",&Poly3$(),8 INPUT "End with [Return]";Dummy Cexit END -Polynomials DATA 1.2,-1,7.5,-2,3.14,3,5.3,7.2 DATA -5.7,-22.13,1,2.5,7,-2.77,11.23,0.123,5.6 DATA 5.4,-2.2,1.3,2,7,-2.33,11.1,2.123,4.56 |
| Cpoly_Sub(&A$(),&B$(),&C$(),M,N) | |
| A$(0:M) | Complex coefficients of the addend. |
| B$(0:N) | Complex coefficients of the subtrahend. |
| C$(0:MAX(M,N)) | Complex coefficients of the difference polynomial. |
| M | Degree of polynomial A$() (highest power). |
| N | Degree of polynomial B$() (highest power). |
| This procedure subtracts the polynomial B$() from the polynomial A$() and returns the results in C$() (C$()=A$()-B$()), which is carried out through the subtraction of the coefficients with the same power. | |
| Cpoly_Mul(&A$(),&B$(),&C$(),M,N) | |
| A$(0:M) | Complex coefficients of the multiplicand. |
| B$(0:N) | Complex coefficients of the multiplier. |
| C$(0:M+N) | Complex coefficients of the product polynomial. |
| M | Degree of polynomial A$() (highest power). |
| N | Degree of polynomial B$() (highest power). |
| This procedure multiplies the polynomial A$() by the polynomial B$() and returns the result in C$()(C$()=A$()*B$()). This is carried out through the component multiplication with subsequent summation of equal powers. | |
| Cpoly_S_Mul(&A$(),Z$,&C$(),N) | |
| A$(0:N) | Complex coefficients of the multiplicand. |
| Z$ | Complex number as multiplier. |
| C$(0:N) | Complex coefficients of the product polynomial. |
| N | Degree of polynomial A$() (highest power). |
| This procedure multiplies the polynomial A$() by the complex number Z$ and returns the result in C$() (C$()=A$()*Z$). This operation is also called a scalar multiplication. | |
| Cpoly_Div(&A$(),&B$(),&C$(),&D$(),L,M,R N,R O) | |
| A$(0:L) | Complex coefficients of the dividend. |
| B$(0:M) | Complex coefficients of the divisor. |
| C$(0:N) | Complex coefficients of the quotient polynomial. |
| D$(0:O) | Complex coefficients of the remainder polynomial. |
| L | Degree of polynomial A$() (highest power). |
| M | Degree of polynomial B$() (highest power). |
| N | Degree of polynomial C$() (highest power). |
| O | Degree of polynomial D$() (highest power). |
| This procedure divides the polynomial A$() by the polynomial B$() and returns the result in C$() and the remainder of the division in D$() (C$()=A$()/B$() and D$()=A$() MOD B$()). If O=0, then the division has no remainder. | |
| Cpoly_S_Div(&A$(),Z$,&C$(),N) | |
| A$(0:N) | Complex coefficients of the dividend. |
| Z$ | Complex number as divisor. |
| C$(0:N) | Complex coefficients of the quotient polynomial. |
| N | Degree of polynomial A$() (highest power). |
| This procedure divides the polynomial A$() by a complex number Z$ and posts the result in C$() (C$()=A$()/Z$). This operation is also called a scalar division. | |
| FN Cpoly_Value$(&A$(),Z$,N) | |
| A$(0:N) | Complex coefficients of the polynomial. |
| Z$ | Complex number. |
| N | Degree of polynomial A$() (highest power). |
| This functions calculates the function value of the polynomial A$() at location Z$ and returns the result as a complex number. | |
| Cpoly_Zeros(&A$(),&C$(),N,R E,R E$) | |
| A$(0:N) | Complex coefficients of the polynomial. |
| C$(0:N) | The procedure returns the complex zero points of the polynomial in this field. |
| N | Degree of polynomial A$() (highest power). |
| E | After the return, this variable can contain the following values: E=0 : no error E=1 : leading coefficient equals zero. E=2 : not all zero points have been located. |
| E$ | If an error has occurred, this string variable contains one of the error texts from the previous field after the return; otherwise, an empty string is returned. |
| This procedure calculates the zero points of the polynomial A$() and returns the result in C$(). | |
| Example: Calculation of the zero points of the polynomial Z^3+(-3+i2)*Z^2+(-12-i12)*Z+30-i20. First, two fields are being dimensioned, namely those for the complex coefficients and the zero points. Then the coefficients are entered into the field. If Cpoly_Zeros does not report any errors, then the result is displayed on the screen; otherwise, an error message is issued. Cinit DIM Poly$(3),Zeros$(2) Poly$(0)=FN Cmplx$(30,-20):Poly$(1)=FN Cmplx$(-12,-12) Poly$(2)=FN Cmplx$(-3,2):Poly$(3)=C_R$ Cpoly_Zeros &Poly$(0),&Zeros$(0),3,E,E$ IF E THEN PRINT "Error No.:";E,E$ ELSE PRINT "Zero points of the polynomial "; PRINT "Z^3+(-3+i2)*Z^2+(-12-i12)*Z+30-i20" FOR I=0 TO 2 PRINT I+1;". Zero point: ";:Cprint Zeros$(I) NEXT I ENDIF PRINT :INPUT "End with [Return]";E Cexit END |
| 2.9 Matrix Functions |
| Matrices are represented in the Complex Library by 2-dimensional string fields. A matrix begins
with the element (0,0). The matrix Z$ (3,3) is thus also a 4x4 matrix and not a 3x3 matrix! What is important is that the result matrix generally may NOT be identical with one of the argument matrices! This is only permitted if so indicated in a few exceptional cases. |
| Cmat_Clear(&A$(,),M,N) | |
| A$(0:M,0:N) | The complex elements of the matrix. |
| M | Highest row number. |
| N | Highest column number. |
| All elements of the matrix A$(,) are set to zero. | |
| Example: Setting the matrix Z$(8,11) to zero. Cinit DIM Z$(8,11) Cmat_Clear &Z$(,),8,11 Cmat_Print_Using "",&Z$(,),8,11 INPUT "End with [Return]";Dummy Cexit END |
| Cmat_Id(&A$(,),N) | |
| A$(0:N,0:N) | The complex elements of the matrix. |
| N | Highest row or column number, respectively (square matrix). |
| This procedure generates a square unit matrix from A$(,). All elements of the main diagonal are set to one and the rest to zero. | |
| Cmat_Equal(&A$(,),&C$(,),M,N) | |
| A$(0:M,0:N) | The complex elements of the source matrix. |
| C$(0:M,0:N) | The complex elements of the target matrix. |
| M | Highest row number. |
| N | Highest column number. |
| The matrix A$(,) is assigned to the matrix C$(,) (C$(,)=A$(,)). This procedure also copies the content of the matrix A$(,) to the matrix C$(,). | |
| Cmat_Herm_Conj(&A$(,),&C$(,),M,N) | |
| A$(0:M,0:N) | The complex elements of the source matrix. |
| C$(0:M,0:N) | The complex elements of the hermetically conjugated matrix. |
| M | Highest row number. |
| N | Highest column number. |
| This procedure calculates the hermetically conjugated matrix for A$(,) and assigns the result to the matrix C$(,). If A$(,) is a square matrix (N=M), then A$(,) may be in concordance with C$(,). | |
| Cmat_Add(&A$(,),&B$(,),&C$(,),M,N) | |
| A$(0:M,0:N) | The complex elements of the first addend matrix. |
| B$(0:M,0:N) | The complex elements of the second addend matrix. |
| C$(0:M,0:N) | The complex elements of the sum matrix. |
| M | Highest row number. |
| N | Highest column number. |
| The matrix A$(,) is added to the matrix B$(,) and the result assigned to the matrix C$(,) (C$(,)=A$(,)+B$(,)). C$(,) may be in concordance with A$(,) or B$(,). | |
| Cmat_Sub(&A$(,),&B$(,),&C$(,),M,N) | |
| A$(0:M,0:N) | The complex elements of the addend matrix. |
| B$(0:M,0:N) | The complex elements of the subtrahend matrix. |
| C$(0:M,0:N) | The complex elements of the difference matrix. |
| M | Highest row number. |
| N | Highest column number. |
| The matrix B$(,) is subtracted from the matrix A$(,) and the result assigned to the matrix C$(,) (C$(,)=A$(,)-B$(,)). C$(,) may be in concordance with A$(,) or B$(,). | |
| Cmat_Mul(&A$(,),&B$(,),&C$(,),L,M,N) | |
| A$(0:L,0:M) | The complex elements of the multiplicand matrix. |
| B$(0:M,0:N) | The complex elements of the multiplier matrix. |
| C$(0:L,0:N) | The complex elements of the product matrix. |
| L | Highest row number of A$(,) and C$(,). |
| M | Highest column number of A$(,) and highest row number of B$(,). |
| N | Highest column number of B$(,) and C$(,). |
| The matrix A$(,) is multiplied with the matrix B$(,) and the result assigned to the matrix C$(,) (C$(,)=A$(,)*B$(,)). Please make sure that the individual matrices have the correct dimensions. | |
| Cmat_S_Mul(&A$(,),Z$,&C$(,),M,N) | |
| A$(0:M,0:N) | The complex elements of the multiplicand matrix. |
| Z$ | Complex number as multiplier. |
| C$(0:M,0:N) | The complex elements of the product matrix. |
| M | Highest row number. |
| N | Highest column number. |
| The matrix A$(,) is multiplied with the complex number Z$ and the result assigned to the matrix C$(,) (C$(,)=A$(,)*Z$. C$(,) may be in concordance with A$(,). This operation is also called a scalar multiplication. | |
| Cmat_S_Div(&A$(,),Z$,&C$(,),M,N) | |
| A$(0:M,0:N) | The complex elements of the dividend matrix. |
| Z$ | Complex number as divisor. |
| C$(0:M,0:N) | The complex elements of the quotient matrix. |
| M | Highest row number. |
| N | Highest column number. |
| The matrix A$(,) is divided by the complex number Z$ and the result assigned to the matrix C$(,) (C$(,)=A$(,)/Z$. C$(,) may be in concordance with A$(,). This operation is also called a scalar division. | |
| Cmat_Inv_By_X(&A$(,),&C$(,),N) | |
| A$(0:N,0:N) | The complex elements of the source matrix. |
| C$(0:N,0:N) | The complex elements of the inverse matrix. |
| N | Highest row and/or column number. |
| This procedure calculates the inverse matrix for A$(,) and assigns the result to the matrix C$(,). The REAL of the matrix A$(,) has to be separately reversible for this procedure, otherwise an error message will be issued. | |
| Cmat_Inv_By_Y(&A$(,),&C$(,),N) | |
| A$(0:N,0:N) | The complex elements of the source matrix. |
| C$(0:N,0:N) | The complex elements of the inverse matrix. |
| N | Highest row and/or column number. |
| This procedure calculates the inverse matrix for A$(,) and assigns the result to the matrix C$(,). The IMAG of the matrix A$(,) has to be separately reversible for this procedure, otherwise an error message will be issued. | |
| Cmat_Inv(&A$(,),&C$(,),N,R D$) | |
| A$(0:N,0:N) | The complex elements of the source matrix. |
| C$(0:N,0:N) | The complex elements of the inverse matrix. |
| N | Highest row and/or column number. |
| D$ | After the return, this contains the determinant of the matrix A$(,). |
| This procedure calculates the inverse matrix for A$(,) and assigns the result to the matrix C$(,). Neither the REAL nor the IMAG of the matrix A$(,) have to be separately reversible for this procedure. Cmat_Inv is thus the most usual inversion, but also requires the longest calculation time. | |
| Cmat_Simeq(&A$(,),&B$(,),&C$(,),N,R E) | |
| A$(0:N,0:N) | The complex coefficients on the left side of the system of equations. |
| B$(0:N,0) | The complex values on the right side of the system of equations. |
| C$(0:N,0) | The complex element |