Main Page   Data Structures   File List   Data Fields   Globals  

scs.h File Reference

This is the main header file of the SCS library, which defines the SCS data structure, and the functions that implement arithmetic on it. More...

Go to the source code of this file.

Data Structures

struct  scs
 The SCS data type. More...


SCS data-types

typedef scsscs_ptr
scs scs_t [1]

Conversion and initialization functions

void scs_get_d (double *, scs_ptr)
void scs_get_d_minf (double *, scs_ptr)
void scs_get_d_pinf (double *, scs_ptr)
void scs_get_d_zero (double *, scs_ptr)
void scs_set_d (scs_ptr, double)
void scs_set_si (scs_ptr, signed int)
void scs_get_std (scs_ptr)
void scs_set (scs_ptr, scs_ptr)
void scs_zero (scs_ptr)
void scs_rand (scs_ptr result, int expo_max)

Addition and renormalisation functions

void scs_add (scs_ptr result, scs_ptr x, scs_ptr y)
void scs_sub (scs_ptr result, scs_ptr x, scs_ptr y)
void scs_add_no_renorm (scs_ptr result, scs_ptr x, scs_ptr y)
void scs_renorm (scs_ptr)
void scs_renorm_no_cancel_check (scs_ptr)

Multiplication functions

void scs_mul (scs_ptr result, const scs_ptr x, const scs_ptr y)
void scs_mul_ui (scs_ptr, const unsigned int)
void scs_square (scs_ptr result, scs_ptr x)
void scs_fma (scs_ptr result, scs_ptr a, scs_ptr b, scs_ptr c)

Divisions

void scs_inv (scs_ptr result, scs_ptr x)
void scs_div (scs_ptr result, scs_ptr x, scs_ptr y)


Detailed Description

This is the main header file of the SCS library, which defines the SCS data structure, and the functions that implement arithmetic on it.

Author:
David Defour David.Defour@ens-lyon.fr , Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr
This file is part of the SCS library.

Copyright (C) 2002 David Defour and Florent de Dinechin

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Definition in file scs.h.


Typedef Documentation

typedef struct scs* scs_ptr
 

scs_ptr is a pointer on a SCS structure.

Definition at line 116 of file scs.h.


Function Documentation

void scs_get_d double *    result,
scs_ptr    x
 

Convert a SCS number to a double, rounding to the nearest.

Warning:
"x" need to be normalized

Definition at line 50 of file scs2double.c.

void scs_get_d_minf double *   ,
scs_ptr   
 

Convert a SCS number to a double, rounding towards minus infinity.

Definition at line 366 of file scs2double.c.

References scs_get_d_minf().

Referenced by scs_get_d_minf().

void scs_get_d_pinf double *   ,
scs_ptr   
 

Convert a SCS number to a double, rounding towards plus infinity.

Definition at line 377 of file scs2double.c.

References scs_get_d_pinf().

Referenced by scs_get_d_pinf().

void scs_get_d_zero double *   ,
scs_ptr   
 

Convert a SCS number to a double, rounding towards zero.

Definition at line 388 of file scs2double.c.

References scs_get_d_zero().

Referenced by scs_get_d_zero().

void scs_set_d scs_ptr   ,
double   
 

Convert a double into a SCS number (this is an exact operation).

Definition at line 36 of file double2scs.c.

Referenced by scs_inv().

void scs_set_si scs_ptr   ,
signed    int
 

Convert an unsigned int into a SCS number (this is an exact operation).

Definition at line 148 of file double2scs.c.

Referenced by scs_inv().

void scs_get_std scs_ptr   
 

Print out a SCS number.

Sorry for the strange name, we are mimicking GMP

Definition at line 59 of file print_scs.c.

void scs_set scs_ptr    result,
scs_ptr    x
[inline]
 

Copy a SCS number into another.

There is an unrolled version for the case SCS_NB_WORDS==8.

Definition at line 55 of file addition_scs.c.

Referenced by scs_add(), scs_inv(), and scs_sub().

void scs_zero scs_ptr    result [inline]
 

Set a SCS number to zero.

There should be a few simple functions in this library.

Definition at line 40 of file zero_scs.c.

void scs_rand scs_ptr    result,
int    expo_max
 

Generate a random SCS number.

The index field of result will be between -expo_max and +expo_max. Example: to get a number in the double-precision floating-point range, expo_max should be smaller than 39.

Warning:
No guarantee is made about the quality of the random algorithm used...

Definition at line 51 of file rand_scs.c.

void scs_add scs_ptr    result,
scs_ptr    x,
scs_ptr    y
[inline]
 

Addition of two SCS numbers.

The arguments x, y and result may point to the same memory location. The result is a normalised SCS number.

Definition at line 514 of file addition_scs.c.

References scs::exception, and scs_set().

void scs_sub scs_ptr    result,
scs_ptr    x,
scs_ptr    y
[inline]
 

Subtraction of two SCS numbers.

The arguments x, y and result may point to the same memory location.

Definition at line 539 of file addition_scs.c.

References scs::exception, and scs_set().

Referenced by scs_inv().

void scs_add_no_renorm scs_ptr    result,
scs_ptr    x,
scs_ptr    y
[inline]
 

Addition without renormalisation, to be used for adding many numbers.

Warning:
In case of a cancellation, severe loss of precision could happen. Safe if the numbers are of the same sign.

Definition at line 224 of file addition_scs.c.

void scs_renorm scs_ptr    result [inline]
 

Renormalisation (to be used after several scs_add_no_renorm).

This function removes the carry from each digit, and also shifts the digits in case of a cancellation (so that if result != 0 then its first digit is non-zero)

Warning:
THIS FUNCTION HAS NEVER BEEN PROPERLY TESTED and is currently unused in the library: instead, specific renormalisation steps are fused within the code of the operations which require it.

Definition at line 84 of file addition_scs.c.

void scs_renorm_no_cancel_check scs_ptr    result [inline]
 

Renormalisation assuming no cancellation.

This renormalization step is especially designed for the addition of several numbers with the same sign. In this case, you know that there has been no cancellation, which allows simpler renormalisation.

Definition at line 137 of file addition_scs.c.

void scs_mul scs_ptr    result,
const scs_ptr    x,
const scs_ptr    y
 

Multiplication of two SCS numbers.

The arguments x, y and result may point to the same memory location. The result is a normalised SCS number.

Definition at line 291 of file multiplication_scs.c.

Referenced by scs_div(), and scs_inv().

void scs_mul_ui scs_ptr   ,
const unsigned    int
 

Multiplication of a SCS with an unsigned integer; result is returned in x.

Definition at line 448 of file multiplication_scs.c.

void scs_square scs_ptr    result,
scs_ptr    x
 

Square.

Result is normalised

Definition at line 378 of file multiplication_scs.c.

void scs_fma scs_ptr    result,
scs_ptr    a,
scs_ptr    b,
scs_ptr    c
 

Fused multiply-and-add (ab+c); Result is normalised.

Warning:
This function has not been tested thoroughly

Definition at line 27 of file poly_fct.c.

void scs_inv scs_ptr    result,
scs_ptr    x
 

SCS inverse.

Stores 1/x in result. Result is normalised

Warning:
This function is known not to work for most precisions: it performs a fixed number of Newton-Raphson iterations (two), starting with a FP number (53 bits), so provides roughly 210 bits of precision. It should be modified to perform more iterations if more precision is needed.

Definition at line 38 of file division_scs.c.

References scs::index, scs_get_d(), scs_mul(), scs_set(), scs_set_d(), scs_set_si(), scs_sub(), and scs_t.

Referenced by scs_div().

void scs_div scs_ptr    result,
scs_ptr    x,
scs_ptr    y
 

SCS division.

Computes x/y. Result is normalised

Warning:
This function is known not to work for most precisions: it performs a fixed number of Newton-Raphson iterations (two), starting with a FP number (53 bits), so provides roughly 210 bits of precision. It should be modified to perform more iterations if more precision is needed.

Definition at line 67 of file division_scs.c.

References scs_inv(), scs_mul(), and scs_t.


Variable Documentation

struct scs scs_t[1]
 

scs_t is an array of one SCS struct to lighten syntax : you may declare a scs_t object, and pass it to the scs functions (which expect pointers) without using ampersands.

Definition at line 125 of file scs.h.

Referenced by scs_div(), and scs_inv().


Generated on Tue Jun 17 10:15:52 2003 for SCSLib by doxygen1.2.15