diff options
Diffstat (limited to 'src/c/elementaryFunctions/round')
-rw-r--r-- | src/c/elementaryFunctions/round/i16rounda.c | 20 | ||||
-rw-r--r-- | src/c/elementaryFunctions/round/i16rounds.c | 23 | ||||
-rw-r--r-- | src/c/elementaryFunctions/round/i8rounda.c | 20 | ||||
-rw-r--r-- | src/c/elementaryFunctions/round/i8rounds.c | 23 | ||||
-rw-r--r-- | src/c/elementaryFunctions/round/u16rounda.c | 20 | ||||
-rw-r--r-- | src/c/elementaryFunctions/round/u16rounds.c | 23 | ||||
-rw-r--r-- | src/c/elementaryFunctions/round/u8rounda.c | 20 | ||||
-rw-r--r-- | src/c/elementaryFunctions/round/u8rounds.c | 23 |
8 files changed, 172 insertions, 0 deletions
diff --git a/src/c/elementaryFunctions/round/i16rounda.c b/src/c/elementaryFunctions/round/i16rounda.c new file mode 100644 index 0000000..5cacafa --- /dev/null +++ b/src/c/elementaryFunctions/round/i16rounda.c @@ -0,0 +1,20 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#include "round.h" + +void i16rounda(int16* x, int size, int16* out) { + int i=0; + + for (i=0;i<size;i++) out[i]=i16rounds(x[i]); +} diff --git a/src/c/elementaryFunctions/round/i16rounds.c b/src/c/elementaryFunctions/round/i16rounds.c new file mode 100644 index 0000000..95bd609 --- /dev/null +++ b/src/c/elementaryFunctions/round/i16rounds.c @@ -0,0 +1,23 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#include "round.h" + +int16 i16rounds(int16 x) { + int result; + + if(x>=0) result = (int16)((float)x+0.5); + else result = (int16)((float)x-0.5); + + return (int16)result; +} diff --git a/src/c/elementaryFunctions/round/i8rounda.c b/src/c/elementaryFunctions/round/i8rounda.c new file mode 100644 index 0000000..c47be51 --- /dev/null +++ b/src/c/elementaryFunctions/round/i8rounda.c @@ -0,0 +1,20 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#include "round.h" + +void i8rounda(int8* x, int size, int8* out) { + int i=0; + + for (i=0;i<size;i++) out[i]=i8rounds(x[i]); +} diff --git a/src/c/elementaryFunctions/round/i8rounds.c b/src/c/elementaryFunctions/round/i8rounds.c new file mode 100644 index 0000000..f37d53c --- /dev/null +++ b/src/c/elementaryFunctions/round/i8rounds.c @@ -0,0 +1,23 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#include "round.h" + +int8 i8rounds(int8 x) { + int result; + + if(x>=0) result = (int8)((float)x+0.5); + else result = (int8)((float)x-0.5); + + return (int8)result; +} diff --git a/src/c/elementaryFunctions/round/u16rounda.c b/src/c/elementaryFunctions/round/u16rounda.c new file mode 100644 index 0000000..38c4b28 --- /dev/null +++ b/src/c/elementaryFunctions/round/u16rounda.c @@ -0,0 +1,20 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#include "round.h" + +void u16rounda(uint16* x, int size, uint16* out) { + int i=0; + + for (i=0;i<size;i++) out[i]=u16rounds(x[i]); +} diff --git a/src/c/elementaryFunctions/round/u16rounds.c b/src/c/elementaryFunctions/round/u16rounds.c new file mode 100644 index 0000000..babda6d --- /dev/null +++ b/src/c/elementaryFunctions/round/u16rounds.c @@ -0,0 +1,23 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#include "round.h" + +uint16 u16rounds(uint16 x) { + int result; + + if(x>=0) result = (uint16)((float)x+0.5); + else result = (uint16)((float)x-0.5); + + return (uint16)result; +} diff --git a/src/c/elementaryFunctions/round/u8rounda.c b/src/c/elementaryFunctions/round/u8rounda.c new file mode 100644 index 0000000..e8f828d --- /dev/null +++ b/src/c/elementaryFunctions/round/u8rounda.c @@ -0,0 +1,20 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#include "round.h" + +void u8rounda(uint8* x, int size, uint8* out) { + int i=0; + + for (i=0;i<size;i++) out[i]=u8rounds(x[i]); +} diff --git a/src/c/elementaryFunctions/round/u8rounds.c b/src/c/elementaryFunctions/round/u8rounds.c new file mode 100644 index 0000000..7e3da17 --- /dev/null +++ b/src/c/elementaryFunctions/round/u8rounds.c @@ -0,0 +1,23 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Arnaud Torset + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#include "round.h" + +uint8 u8rounds(uint8 x) { + int result; + + if(x>=0) result = (uint8)((float)x+0.5); + else result = (uint8)((float)x-0.5); + + return (uint8)result; +} |