### Compile and Link Example.c using hpaconf Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Example of compiling and linking a single-file C program in one step using the combined output of `hpaconf -c -l`. This example is for sh-compatible shells. ```bash cc example.c $(hpaconf -c -l) -o example ``` ```bash cc example.c `hpaconf -c -l` -o example ``` -------------------------------- ### Compile Example.c using hpaconf for flags Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Example of compiling a C source file using the output of `hpaconf -c` to specify include paths. This example is for sh-compatible shells. ```bash cc -c $(hpaconf -c) example.c ``` ```bash cc -c `hpaconf -c` example.c ``` -------------------------------- ### Link Example.o using hpaconf for flags Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Example of linking an object file using the output of `hpaconf -l` to specify library paths. This example is for sh-compatible shells. ```bash cc example.o $(hpaconf -l) -o example ``` ```bash cc example.o `hpaconf -l` -o example ``` -------------------------------- ### Audio Buffer Get Sample Format Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Retrieves the sample format of an AudioBuffer. ```c static inline int audio_buffer_get_sample_format(const struct AudioBuffer *buf) { return buf->format; } ``` -------------------------------- ### Add jdsp configuration to audio_effects.conf Source: https://github.com/james34602/jamesdspmanager/blob/master/README.md This snippet shows how to add the jdsp configuration to the audio_effects.conf file for manual installation. Ensure this is added under the 'bundle' section. ```text jdsp { path /system/lib/soundfx/libjamesdsp.so } ``` -------------------------------- ### Complex Number Formatting Example (ALT) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Shows how to print a complex number using custom delimiters specified by ldel and rdel fields in xoutflags. ```c a, b ``` -------------------------------- ### Compiling a C++ file with hpaxxconf (compile only) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Example command to compile a C++ source file using hpaxxconf for C++ wrapper compilation flags. ```Shell c++ -c $(hpaxxconf -c) example.cc ``` -------------------------------- ### Complex Number Formatting Example (RAW) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Illustrates printing a complex number in the RAW format, with two spaces separating the real and imaginary parts. ```c 1.0 2.5 ``` -------------------------------- ### HPA Library Error Handling Example Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Demonstrates how to handle domain errors when using the xsqrt function by checking the xErrNo variable. The error indicator is reset to zero before each function call to ensure accurate error detection. ```c #include #include extern int xErrNo; int main (void) { int n; struct xpr sr; do { printf ("Give me a number, n = ? "); scanf ("%d", &n); xErrNo = 0; sr = xsqrt (inttox (n)); if (xErrNo == 0) { printf ("The square root of %d is\n", n); xprxpr (sr, 30); putchar ('\n'); } else fprintf (stderr, "*** Error: Out of domain\n"); } while (n != 0); return 0; } ``` -------------------------------- ### Linking object files with hpaxxconf Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Example command to link object files into an executable using hpaxxconf for C++ wrapper linkage flags. ```Shell c++ example.o $(hpaxxconf -l) -o example ``` -------------------------------- ### Print HPA Version Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Use this command to display the installed version of the HPA library. It can be combined with the -n option to add a newline. ```bash hpaconf -v ``` ```bash hpaconf -v -n ``` ```bash hpaconf -n -v ``` -------------------------------- ### C++ Factorial Function Example Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Example of computing the factorial of an integer using the xreal type for high-precision calculations. ```C++ // Compute the factorial of the integer n xreal factorial(xreal n) { xreal i; xreal product = 1; for (i=2; i <= n; i++) product *= i; return product; } ``` -------------------------------- ### Audio Buffer Get Size Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Retrieves the size in bytes of an AudioBuffer. ```c static inline size_t audio_buffer_get_size(const struct AudioBuffer *buf) { return buf->size; } ``` -------------------------------- ### HPA Library Usage Example Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt A sample C program demonstrating the use of the HPA library to calculate the sum of powers of 2. It utilizes functions like xpr2() and xprxpr(). ```c #include #include int main (void) { struct xpr s; int i, n; do { printf ("Give me a number, n = ? "); scanf ("%d", &n); s = xZero; for (i = 0; i <= n; i++) s = xadd (s, xpr2(xOne, i), 0); printf ("The sum 2^0 + 2^1 + ... + 2^n is equal to\n"); xprxpr (s, 30); putchar ('\n'); } while (n > 0); return 0; } ``` -------------------------------- ### Audio Buffer Get Data Pointer Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Retrieves the data pointer of an AudioBuffer. ```c static inline void *audio_buffer_get_data_pointer(const struct AudioBuffer *buf) { return buf->data; } ``` -------------------------------- ### Formatting Control Functions Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Static methods to set and get formatting options for complex number output. ```APIDOC ## xcomplex::set_fmt (short format) ### Description Sets the 'fmt' field of the `xcomplex::ioflags` structure. ### Method `static void set_fmt (short format)` ### Parameters * **format** (short) - The value to set for the format. ## xcomplex::set_notation (short notat) ### Description Sets the 'notat' field of the `xcomplex::ioflags` structure. ### Method `static void set_notation (short notat)` ### Parameters * **notat** (short) - The value to set for the notation. ## xcomplex::set_signflag (short onoff) ### Description Sets the 'sf' field of the `xcomplex::ioflags` structure. ### Method `static void set_signflag (short onoff)` ### Parameters * **onoff** (short) - The value to set for the sign flag. ## xcomplex::set_mfwd (short wd) ### Description Sets the 'mfwd' field of the `xcomplex::ioflags` structure. ### Method `static void set_mfwd (short wd)` ### Parameters * **wd** (short) - The value to set for the mfwd field. ## xcomplex::set_lim (short lim) ### Description Sets the 'lim' field of the `xcomplex::ioflags` structure. ### Method `static void set_lim (short lim)` ### Parameters * **lim** (short) - The value to set for the lim field. ## xcomplex::set_padding (signed char ch) ### Description Sets the 'padding' field of the `xcomplex::ioflags` structure. ### Method `static void set_padding (signed char ch)` ### Parameters * **ch** (signed char) - The value to set for padding. ## xcomplex::set_ldelim (signed char ch) ### Description Sets the 'ldel' field of the `xcomplex::ioflags` structure. ### Method `static void set_ldelim (signed char ch)` ### Parameters * **ch** (signed char) - The value to set for the left delimiter. ## xcomplex::set_rdelim (signed char ch) ### Description Sets the 'rdel' field of the `xcomplex::ioflags` structure. ### Method `static void set_rdelim (signed char ch)` ### Parameters * **ch** (signed char) - The value to set for the right delimiter. ## xcomplex::get_fmt (void) ### Description Returns the current value of the 'fmt' field of the `xcomplex::ioflags` structure. ### Method `static short get_fmt (void)` ### Return Value * **short** - The current format value. ## xcomplex::get_notation (void) ### Description Returns the current value of the 'notat' field of the `xcomplex::ioflags` structure. ### Method `static short get_notation (void)` ### Return Value * **short** - The current notation value. ## xcomplex::get_signflag (void) ### Description Returns the current value of the 'sf' field of the `xcomplex::ioflags` structure. ### Method `static short get_signflag (void)` ### Return Value * **short** - The current sign flag value. ## xcomplex::get_mfwd (void) ### Description Returns the current value of the 'mfwd' field of the `xcomplex::ioflags` structure. ### Method `static short get_mfwd (void)` ### Return Value * **short** - The current mfwd value. ## xcomplex::get_lim (void) ### Description Returns the current value of the 'lim' field of the `xcomplex::ioflags` structure. ### Method `static short get_lim (void)` ### Return Value * **short** - The current lim value. ## xcomplex::get_padding (void) ### Description Returns the current value of the 'padding' field of the `xcomplex::ioflags` structure. ### Method `static signed char get_padding (void)` ### Return Value * **signed char** - The current padding value. ## xcomplex::get_ldelim (void) ### Description Returns the current value of the 'ldel' field of the `xcomplex::ioflags` structure. ### Method `static signed char get_ldelim (void)` ### Return Value * **signed char** - The current left delimiter value. ## xcomplex::get_rdelim (void) ### Description Returns the current value of the 'rdel' field of the `xcomplex::ioflags` structure. ### Method `static signed char get_rdelim (void)` ### Return Value * **signed char** - The current right delimiter value. ``` -------------------------------- ### Audio Buffer Get Channel Count Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Calculates the number of audio channels in a buffer based on its format. ```c static inline size_t audio_buffer_get_channel_count(const struct AudioBuffer *buf) { switch (buf->format) { case AUDIO_FORMAT_PCM_8_BIT: case AUDIO_FORMAT_PCM_16_BIT: case AUDIO_FORMAT_PCM_24_BIT_PACKED: case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_FLOAT: return 1; case AUDIO_FORMAT_PCM_8_BIT_STEREO: case AUDIO_FORMAT_PCM_16_BIT_STEREO: case AUDIO_FORMAT_PCM_24_BIT_PACKED_STEREO: case AUDIO_FORMAT_PCM_32_BIT_STEREO: case AUDIO_FORMAT_PCM_FLOAT_STEREO: return 2; default: return 0; } } ``` -------------------------------- ### Audio Buffer Get Frame Count Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Calculates the number of audio frames in a buffer based on its size and format. ```c static inline size_t audio_buffer_get_frame_count(const struct AudioBuffer *buf) { switch (buf->format) { case AUDIO_FORMAT_PCM_8_BIT: case AUDIO_FORMAT_PCM_16_BIT: case AUDIO_FORMAT_PCM_24_BIT_PACKED: case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_FLOAT: return buf->size / audio_bytes_per_sample(buf->format); default: return 0; } } ``` -------------------------------- ### Audio Buffer Initialization Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Initializes an AudioBuffer structure with provided data, size, and format. Sets format to invalid if data is NULL. ```c static inline void audio_buffer_init(struct AudioBuffer *buf, void *data, size_t size, int format) { buf->data = data; buf->size = size; buf->format = data ? format : AUDIO_BUFFER_FORMAT_INVALID; } ``` -------------------------------- ### C++ Main Program with High-Precision Input/Output Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt A complete C++ program demonstrating high-precision input and output using the xreal class and standard C++ streams. ```C++ #include #include using namespace HPA; int main (void) { xreal x; while ( x.getfrom(cin) > 0 ) cout << "The square root of 2 * " << x << " + 1 is " << sqrt(2 * x + 1) << endl; return 0; } ``` -------------------------------- ### Get Imaginary Part of Complex Number with cxim Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Retrieves the imaginary part of a complex number. A macro is available for direct access. ```c struct xpr cxim (struct cxpr z) ``` ```c #define CXIM(z) (z).im ``` -------------------------------- ### Get Real Part of Complex Number with cxre Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Retrieves the real part of a complex number. A macro is available for direct access. ```c struct xpr cxre (struct cxpr z) ``` ```c #define CXRE(z) (z).re ``` -------------------------------- ### Compiling and linking a C++ file with hpaxxconf (alternative syntax) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Alternative syntax for compiling and linking a C++ source file using hpaxxconf, using backticks for command substitution. ```Shell c++ example.cc `hpaxxconf -c -l` -o example ``` -------------------------------- ### Compiling a C++ file with hpaxxconf (compile only, alternative syntax) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Alternative syntax for compiling a C++ source file using hpaxxconf, employing backticks for command substitution. ```Shell c++ -c `hpaxxconf -c` example.cc ``` -------------------------------- ### xexp2 - Compute the base-2 exponential function. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the base-2 exponential function 2^x for an extended precision number. ```APIDOC ## xexp2 - Compute the base-2 exponential function. ### Description Computes the base-2 exponential function 2^x for an extended precision number. ### Method `struct xpr xexp2(struct xpr x)` ### Parameters #### Input Structure - **x** (struct xpr) - Structure containing the function argument. ### Return Value - **struct xpr** - 2 raised to x. ``` -------------------------------- ### I/O Flag Configuration Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Static methods to configure the I/O formatting flags for extended precision number output. ```APIDOC ## set_notation (short notat) ### Description Sets the 'notat' field of the static `xreal::ioflags` structure, controlling the notation format for output. ### Method `static void set_notation(short notat)` ### Parameters * **notat** (short) - The value to set for the notation format. ``` ```APIDOC ## set_signflag (short onoff) ### Description Sets the 'sf' field of the static `xreal::ioflags` structure, controlling the sign flag for output. ### Method `static void set_signflag(short onoff)` ### Parameters * **onoff** (short) - The value to set for the sign flag. ``` ```APIDOC ## set_mfwd (short wd) ### Description Sets the 'mfwd' field of the static `xreal::ioflags` structure. ### Method `static void set_mfwd(short wd)` ### Parameters * **wd** (short) - The value to set for the 'mfwd' field. ``` ```APIDOC ## set_lim (short lim) ### Description Sets the 'lim' field of the static `xreal::ioflags` structure, likely controlling a limit for output formatting. ### Method `static void set_lim(short lim)` ### Parameters * **lim** (short) - The value to set for the limit. ``` ```APIDOC ## set_padding (signed char ch) ### Description Sets the 'padding' field of the static `xreal::ioflags` structure, controlling padding characters for output. ### Method `static void set_padding(signed char ch)` ### Parameters * **ch** (signed char) - The character to use for padding. ``` -------------------------------- ### xexp - Compute the exponential function. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the exponential function e^x for an extended precision number. ```APIDOC ## xexp - Compute the exponential function. ### Description Computes the exponential function e^x for an extended precision number. ### Method `struct xpr xexp(struct xpr x)` ### Parameters #### Input Structure - **x** (struct xpr) - Structure containing the function argument. ### Return Value - **struct xpr** - e (the base of natural logarithms) raised to x. ``` -------------------------------- ### xexp10 - Compute the base-10 exponential function. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the base-10 exponential function 10^x for an extended precision number. ```APIDOC ## xexp10 - Compute the base-10 exponential function. ### Description Computes the base-10 exponential function 10^x for an extended precision number. ### Method `struct xpr xexp10(struct xpr x)` ### Parameters #### Input Structure - **x** (struct xpr) - Structure containing the function argument. ### Return Value - **struct xpr** - 10 raised to x. ``` -------------------------------- ### xreal exp() Method Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Returns the exponent part of the binary representation of an xreal number. ```cpp int exp() const; ``` -------------------------------- ### cxout - Print an extended precision complex number to stdout with I/O flags. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Prints an extended precision complex number to standard output (stdout) according to a given set of I/O flags defined in the `xoutflags` structure. ```APIDOC ## cxout ### Description Prints an extended precision complex number on stdout according to a given set of I/O flags. ### Method `int cxout (struct xoutflags ofs, struct cxpr z)` ### Parameters #### Arguments - **ofs** (struct xoutflags) - Structure containing all I/O flags. - **z** (struct cxpr) - Structure containing the complex number to print. ### Return Value - 0 in case of success. - -1 in case of failure. ### Remark For the definition of struct xoutflags and the meaning of its fields see section "Real Arithmetic" (#real_arith). cxout() does not add any newline at the end of the printed number. ``` -------------------------------- ### Linking object files with hpaxxconf (alternative syntax) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Alternative syntax for linking object files using hpaxxconf, utilizing backticks for command substitution. ```Shell c++ example.o `hpaxxconf -l` -o example ``` -------------------------------- ### Display HPA Usage and Build Features Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Calling hpaconf without any options displays usage instructions and detailed build-time features of the HPA library, including floating-point representation and accuracy. ```bash hpaconf ``` -------------------------------- ### xreal Constructors Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Constructors for xreal allow initialization from various types including other xreal objects, primitive numeric types, and strings. ```cpp xreal (const struct xpr* px = &xZero); xreal (struct xpr x); xreal (double x); xreal (float x); xreal (int n); xreal (long n); xreal (unsigned int u); xreal (unsigned long u); ``` ```cpp xreal (const char* str, char** endptr = 0); xreal (string str); xreal (const xreal& x); ``` -------------------------------- ### cxlog - Compute natural (base e) logarithm of a complex number. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the natural logarithm (base e) of a complex number. ```APIDOC ## cxlog ### Description Compute natural (base e) logarithm of a complex number. ### Method `struct cxpr cxlog (struct cxpr z)` ### Parameters #### Arguments - **z** (struct cxpr) - Structure containing the complex number argument. ``` -------------------------------- ### Add jamesdsp effect configuration to audio_effects.conf Source: https://github.com/james34602/jamesdspmanager/blob/master/README.md This snippet shows how to add the jamesdsp effect configuration to the audio_effects.conf file. Ensure this is added under the 'effects' section. ```text jamesdsp { library jdsp uuid f27317f4-c984-4de6-9a90-545759495bf2 } ``` -------------------------------- ### cxfout - Print an extended precision complex number to a file with I/O flags. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Prints an extended precision complex number to a specified file stream according to a given set of I/O flags defined in the `xoutflags` structure. ```APIDOC ## cxfout ### Description Prints an extended precision complex number to a file according to a given set of I/O flags. ### Method `int cxfout (FILE * stream, struct xoutflags ofs, struct cxpr z)` ### Parameters #### Arguments - **stream** (FILE *) - File stream where the number must be printed. - **ofs** (struct xoutflags) - Structure containing all I/O flags. - **z** (struct cxpr) - Structure containing the complex number to print. ### Return Value - 0 in case of success. - -1 in case of failure. ### Remark For the definition of struct xoutflags and the meaning of its fields see section "Real Arithmetic" (#real_arith). cxfout() does not add any newline at the end of the printed number. ``` -------------------------------- ### xlog - Compute natural (base e) logarithms. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the natural logarithm (base e) of an extended precision number. ```APIDOC ## xlog - Compute natural (base e) logarithms. ### Description Computes the natural logarithm (base e) of an extended precision number. ### Method `struct xpr xlog(struct xpr x)` ### Parameters #### Input Structure - **x** (struct xpr) - Structure containing the function argument. ### Return Value - **struct xpr** - The natural logarithm of the argument. ### Remarks A null or negative argument results in a domain error. ``` -------------------------------- ### cxlog2 Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the base-2 logarithm of a complex number. A null argument results in a domain error. ```APIDOC ## cxlog2 ### Description Computes the base-2 logarithm of its complex argument `z`. A null argument results in a domain error. ### Function Signature `struct cxpr cxlog2 (struct cxpr z)` ### Parameters #### Argument - **z** (struct cxpr) - Structure containing the complex number argument. ``` -------------------------------- ### Complex Constants Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt The header file cxpre.h defines constants for zero, one, and the imaginary unit for extended precision complex numbers. ```APIDOC ## Complex Constants The following constants are defined in `cxpre.h`: - `cxZero`: Represents the complex number 0 + 0i. - `cxOne`: Represents the complex number 1 + 0i. - `cxIU`: Represents the imaginary unit 0 + 1i. ``` -------------------------------- ### xsqrt - Compute the square root of an extended precision number. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the square root of an extended precision number. A negative argument results in a domain error. ```APIDOC ## xsqrt - Compute the square root of an extended precision number. ### Description Computes the square root of an extended precision number. ### Method `struct xpr xsqrt(struct xpr x)` ### Parameters #### Input Structure - **x** (struct xpr) - Structure containing the input number. ### Return Value - **struct xpr** - The square root of the input number. ### Remarks A negative argument results in a domain error. ``` -------------------------------- ### Audio Bytes Per Sample Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Returns the number of bytes per audio sample for a given format. Returns 0 for invalid formats. ```c static inline size_t audio_bytes_per_sample(int format) { switch (format) { case AUDIO_FORMAT_PCM_8_BIT: return 1; case AUDIO_FORMAT_PCM_16_BIT: return 2; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return 3; case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_FLOAT: return 4; default: return 0; } } ``` -------------------------------- ### Audio Buffer Structure Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Defines the structure for an audio buffer, including a pointer to the data, the size in bytes, and the sample format. ```c #define AUDIO_BUFFER_FORMAT_INVALID 0 struct AudioBuffer { void *data; size_t size; int format; }; ``` -------------------------------- ### cxexp2 - Compute the base-2 complex exponential function. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the complex exponential function with base 2, calculating 2 raised to the power of the input complex number z. ```APIDOC ## cxexp2 ### Description Compute the base-2 complex exponential function. ### Method `struct cxpr cxexp2 (struct cxpr z)` ### Parameters #### Arguments - **z** (struct cxpr) - Structure containing the function argument. ### Return Value Returns 2 raised to z. ``` -------------------------------- ### Compiling and linking a C++ file with hpaxxconf Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Command to simultaneously compile and link a C++ source file using hpaxxconf, combining compile and link flags. ```Shell c++ example.cc $(hpaxxconf -c -l) -o example ``` -------------------------------- ### xlog2 - Compute base-2 logarithms. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the base-2 logarithm of an extended precision number. ```APIDOC ## xlog2 - Compute base-2 logarithms. ### Description Computes the base-2 logarithm of an extended precision number. ### Method `struct xpr xlog2(struct xpr x)` ### Parameters #### Input Structure - **x** (struct xpr) - Structure containing the function argument. ### Return Value - **struct xpr** - The base-2 logarithm of the argument. ### Remarks A null or negative argument results in a domain error. ``` -------------------------------- ### C++ High-Precision Square Root Calculation Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Demonstrates the compact C++ syntax for performing high-precision mathematical operations, specifically calculating a square root. ```C++ xreal x; while ( x.getfrom(cin) > 0 ) cout << "The square root of 2 * " << x << " + 1 is " << sqrt(2 * x + 1) << endl; ``` -------------------------------- ### cxexp10 - Compute the base-10 complex exponential function. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the complex exponential function with base 10, calculating 10 raised to the power of the input complex number z. ```APIDOC ## cxexp10 ### Description Compute the base-10 complex exponential function. ### Method `struct cxpr cxexp10 (struct cxpr z)` ### Parameters #### Arguments - **z** (struct cxpr) - Structure containing the function argument. ### Return Value Returns 10 raised to z. ``` -------------------------------- ### cxlog10 Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the base-10 logarithm of a complex number. A null argument results in a domain error. ```APIDOC ## cxlog10 ### Description Computes the base-10 logarithm of its complex argument `z`. A null argument results in a domain error. ### Function Signature `struct cxpr cxlog10 (struct cxpr z)` ### Parameters #### Argument - **z** (struct cxpr) - Structure containing the complex number argument. ``` -------------------------------- ### cxexp - Compute the complex exponential function. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the complex exponential function, calculating e (the base of natural logarithms) raised to the power of the input complex number z. ```APIDOC ## cxexp ### Description Compute the complex exponential function. ### Method `struct cxpr cxexp (struct cxpr z)` ### Parameters #### Arguments - **z** (struct cxpr) - Structure containing the function argument. ### Return Value Returns e (the base of natural logarithms) raised to z. ``` -------------------------------- ### Including the Real Arithmetic Header Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Illustrates the necessary include directive for using the HPA library's real number functions and types. ```c #include ``` -------------------------------- ### Constants Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Declaration of useful mathematical constants as `xreal` objects. ```APIDOC ## Constants ### Description Provides access to predefined mathematical constants for extended precision arithmetic. ### Available Constants: * `xZERO` (xreal): 0 * `xONE` (xreal): 1 * `xTWO` (xreal): 2 * `xTEN` (xreal): 10 * `xINF` (xreal): +Infinity * `x_INF` (xreal): -Infinity * `xNAN` (xreal): Not-A-Number * `xPI` (xreal): Pi * `xPI2` (xreal): Pi / 2 * `xPI4` (xreal): Pi / 4 * `xEE` (xreal): e (base of natural logarithms) * `xSQRT2` (xreal): Square root of 2 * `xLN2` (xreal): Natural logarithm of 2 * `xLN10` (xreal): Natural logarithm of 10 * `xLOG2_E` (xreal): Base-2 logarithm of e * `xLOG2_10` (xreal): Base-2 logarithm of 10 * `xLOG10_E` (xreal): Base-10 logarithm of e ``` -------------------------------- ### xcomplex Constructors Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Various constructors are available to initialize an xcomplex number from different types, including other complex types, real numbers, integers, strings, and copy construction. ```APIDOC ## xcomplex Constructors ### Description Initializes an `xcomplex` number. ### Constructors - `xcomplex (const struct cxpr* pz = &cxZero);` - `xcomplex (struct cxpr z);` - `xcomplex (struct xpr x, struct xpr y = xZero);` - `xcomplex (xreal x, xreal y = xZERO);` - `xcomplex (double x, double y = 0.0);` - `xcomplex (float x, float y = 0.0);` - `xcomplex (int m, int n = 0);` - `xcomplex (long m, long n = 0);` - `xcomplex (unsigned int u, unsigned int v = 0U);` - `xcomplex (unsigned long u, unsigned long v = 0U);` - `xcomplex (const char* str, char** endptr = 0);` - Parses a string to create a complex number. If `endptr` is provided, it's updated to point after the parsed characters. - `xcomplex (string str);` - `xcomplex (const xcomplex& z);` (Copy constructor) ``` -------------------------------- ### Round Up to Smallest Integral Value (xceil) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Rounds an extended precision number up to the smallest integral value not less than itself. ```C struct xpr xceil (struct xpr s) ``` -------------------------------- ### Function Name Conventions Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Lists functions that are exceptions to the naming convention, ending in 'tox' or 'tocx'. ```c strtox(), strtocx(), atox(), atocx(), ``` ```c dbltox(), dctocx(), flttox(), fctocx(), ``` ```c inttox(), ictocx(), uinttox(), uctocx(); ``` -------------------------------- ### Audio Buffer Is Valid Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Checks if an AudioBuffer is valid, meaning it has non-NULL data, a non-zero size, and a valid format. ```c static inline bool audio_buffer_is_valid(const struct AudioBuffer *buf) { return buf->data != NULL && buf->size > 0 && buf->format != AUDIO_BUFFER_FORMAT_INVALID; } ``` -------------------------------- ### xlog10 - Compute base-10 logarithms. Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Computes the base-10 logarithm of an extended precision number. ```APIDOC ## xlog10 - Compute base-10 logarithms. ### Description Computes the base-10 logarithm of an extended precision number. ### Method `struct xpr xlog10(struct xpr x)` ### Parameters #### Input Structure - **x** (struct xpr) - Structure containing the function argument. ### Return Value - **struct xpr** - The base-10 logarithm of the argument. ### Remarks A null or negative argument results in a domain error. ``` -------------------------------- ### Input and Output Operations Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Methods for reading complex numbers from input streams and writing them to output streams, along with string conversion capabilities. ```APIDOC ## xcomplex::getfrom (istream& is) ### Description Recovers an extended precision complex number from an input stream. It handles leading whitespace, reads until a whitespace or EOF, and attempts conversion. Errors result in xNAN + xNANi, and overflow sets values to xINF or x_INF. ### Method `int getfrom (istream& is)` ### Parameters * **is** (istream&) - The input stream to read from. ### Return Value * **int** - Returns 0 on input error (e.g., End-Of-File), otherwise non-zero. ## xcomplex::print (ostream& os, int sc_not, int sign, int lim) const ### Description Writes an extended precision complex number to an output stream with specified formatting. ### Method `int print (ostream& os, int sc_not, int sign, int lim) const` ### Parameters * **os** (ostream&) - The output stream to write to. * **sc_not** (int) - Formatting flag (similar to 'notat' in xoutflags). * **sign** (int) - Formatting flag (similar to 'sf' in xoutflags). * **lim** (int) - Formatting flag (similar to 'lim' in xoutflags). ### Return Value * **int** - Indicates success or failure of the print operation. ## xcomplex::asprint (int sc_not, int sign, int lim) const ### Description Returns a character buffer containing the decimal ASCII string representation of the complex number, formatted according to the provided arguments. ### Method `char* asprint (int sc_not, int sign, int lim) const` ### Parameters * **sc_not** (int) - Formatting flag (similar to 'notat' in xoutflags). * **sign** (int) - Formatting flag (similar to 'sf' in xoutflags). * **lim** (int) - Formatting flag (similar to 'lim' in xoutflags). ### Return Value * **char*** - A pointer to a malloc'ed buffer containing the string representation, or NULL if memory allocation fails. ``` -------------------------------- ### I/O Flag Retrieval Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Static methods to retrieve the current values of the I/O formatting flags. ```APIDOC ## get_notation (void) ### Description Retrieves the current value of the 'notat' field from the static `xreal::ioflags` structure. ### Method `static short get_notation(void)` ### Return Value The current notation format setting. ``` ```APIDOC ## get_signflag (void) ### Description Retrieves the current value of the 'sf' field from the static `xreal::ioflags` structure. ### Method `static short get_signflag(void)` ### Return Value The current sign flag setting. ``` ```APIDOC ## get_mfwd (void) ### Description Retrieves the current value of the 'mfwd' field from the static `xreal::ioflags` structure. ### Method `static short get_mfwd(void)` ### Return Value The current 'mfwd' setting. ``` ```APIDOC ## get_lim (void) ### Description Retrieves the current value of the 'lim' field from the static `xreal::ioflags` structure. ### Method `static short get_lim(void)` ### Return Value The current limit setting. ``` ```APIDOC ## get_padding (void) ### Description Retrieves the current value of the 'padding' field from the static `xreal::ioflags` structure. ### Method `static signed char get_padding(void)` ### Return Value The current padding character setting. ``` -------------------------------- ### Input and Output Operations Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Methods for reading extended precision numbers from input streams and printing them to output streams. ```APIDOC ## getfrom (istream& is) ### Description Reads an extended precision number from an input stream. It parses the stream until a whitespace or EOF is encountered, then attempts to convert the read string into an extended precision number. If conversion fails, the number is set to xNAN. Overflow conditions result in xINF or x_INF. ### Method `int getfrom(istream& is)` ### Parameters * **is** (istream&) - The input stream to read from. ### Return Value An integer indicating the success or failure of the operation (details not specified in source). ``` ```APIDOC ## print (ostream& os, int sc_not, int sign, int lim) const ### Description Writes an extended precision number to an output stream with specified formatting. ### Method `int print(ostream& os, int sc_not, int sign, int lim) const` ### Parameters * **os** (ostream&) - The output stream to write to. * **sc_not** (int) - Formatting parameter, related to 'notat' in xoutflags. * **sign** (int) - Formatting parameter, related to 'sf' in xoutflags. * **lim** (int) - Formatting parameter, related to 'lim' in xoutflags. ### Return Value An integer indicating the success or failure of the operation (details not specified in source). ``` ```APIDOC ## asprint (int sc_not, int sign, int lim) const ### Description Converts an extended precision number into a character buffer representing its decimal ASCII string format, using specified formatting parameters. ### Method `char* asprint(int sc_not, int sign, int lim) const` ### Parameters * **sc_not** (int) - Formatting parameter, related to 'notat' in xoutflags. * **sign** (int) - Formatting parameter, related to 'sf' in xoutflags. * **lim** (int) - Formatting parameter, related to 'lim' in xoutflags. ### Return Value A pointer to a character buffer containing the string representation. Returns NULL if memory allocation fails. The buffer is malloc'ed and must be freed by the caller. ``` -------------------------------- ### Print Extended Precision Number in Binary Format (xbprint) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Prints an extended precision number to a specified file stream in binary format. Useful for bit-oriented analysis of rounding errors. Appends a newline character. ```C void xbprint (FILE* stream, struct xpr u) ``` -------------------------------- ### Audio Buffer Copy Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Copies data from a source AudioBuffer to a destination AudioBuffer. Ensures the destination has enough capacity. ```c static inline bool audio_buffer_copy(struct AudioBuffer *dst, const struct AudioBuffer *src) { if (dst->size < src->size) { return false; } if (src->data && src->size > 0) { memcpy(dst->data, src->data, src->size); } dst->size = src->size; return true; } ``` -------------------------------- ### xreal isneg() Method Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Checks if an xreal number is negative. Returns 1 if negative, 0 otherwise. ```cpp int isneg() const; ``` -------------------------------- ### Formatted Output for Extended Precision Number (xfout) Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Prints an extended precision number to a file stream according to a specified set of I/O flags defined by struct xoutflags. ```C int xfout (FILE * stream, struct xoutflags ofs, struct xpr x) ``` -------------------------------- ### xreal getfrom() Method Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Recovers an extended precision number from an input stream. Returns 0 on input error. ```cpp istream& getfrom (istream& is); ``` -------------------------------- ### Convert Real to Complex with cxconv Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Converts a real number into a complex number with a zero imaginary part. A macro version is also provided. ```c struct cxpr cxconv (struct xpr x) ``` ```c #define CXCONV(x) (struct cxpr){x, xZero} ``` -------------------------------- ### xsgn Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Obtains the sign of a number. Returns 0 if the number is zero or invalid, 1 if positive, and -1 if negative. Positive infinity is considered positive, negative infinity is considered negative. ```APIDOC ## xsgn ### Description Obtains the sign of a number. ### Parameters - **u** (const struct xpr *) - Pointer to a structure containing a number. ### Return Value - Returns 0 when *u is zero or is an invalid number (not-a-number). - Returns 1 if *u is positive. - Returns -1 if *u is negative. ### Remark xPinf is considered a positive value, xMinf a negative value. ``` -------------------------------- ### Create Complex Number with cxreset Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Creates a new complex number from its real and imaginary parts. This function is also available as a macro for convenience. ```c struct cxpr cxreset (struct xpr re, struct xpr im) ``` ```c #define CXRESET(re, im) (struct cxpr){re, im} ``` -------------------------------- ### cxroot Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Calculates the i-th branch of the n-th root of a complex number. Handles specific error conditions related to zero or negative exponents and zero modulus. ```APIDOC ## cxroot ### Description Calculates the i-th branch of the n-th root of a complex number `z`. A `bad-exponent` error is produced if `n` is zero or negative and the modulus of `z` is zero. ### Function Signature ```c struct cxpr cxroot (struct cxpr z, int i, int n) ``` ### Parameters - **z** (struct cxpr) - The complex number for which to find the root. - **i** (int) - The index of the branch to return (0-based). - **n** (int) - The degree of the root. ### Returns The i-th branch of the n-th root of `z`. ``` -------------------------------- ### xpow Source: https://github.com/james34602/jamesdspmanager/blob/master/Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/eel2/numericSys/HPFloat/doc/hpa.txt Calculates the power of a base raised to an exponent. The base must be greater than zero. ```APIDOC ## xpow ### Description Calculates the power of a base raised to an exponent. ### Synopsis ```c struct xpr xpow (struct xpr x, struct xpr y) ``` ### Parameters - **x** (struct xpr) - The base. Must be greater than zero. - **y** (struct xpr) - The exponent. ### Return Value The power of the first argument raised to the second one. ``` -------------------------------- ### Audio Buffer Zero Fill Source: https://github.com/james34602/jamesdspmanager/blob/master/linksRegardingDatatype.txt Fills the specified size of an AudioBuffer with zeros. Ensures the buffer has enough capacity. ```c static inline bool audio_buffer_zero_fill(struct AudioBuffer *buf, size_t size) { if (buf->size < size) { return false; } memset(buf->data, 0, size); buf->size = size; return true; } ```