summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/matrixOperations
diff options
context:
space:
mode:
authorimushir2016-02-09 16:38:27 +0530
committerimushir2016-02-09 16:38:27 +0530
commita6efab1a42eda8c1e3902c2f2d030a9cb9cfd25e (patch)
tree70d366ae6a84d201f23895071a8064068e77011f /2.3-1/src/c/matrixOperations
parent7bc57b2061931e5b5843ac6616591b7cff9e9476 (diff)
downloadScilab2C-a6efab1a42eda8c1e3902c2f2d030a9cb9cfd25e.tar.gz
Scilab2C-a6efab1a42eda8c1e3902c2f2d030a9cb9cfd25e.tar.bz2
Scilab2C-a6efab1a42eda8c1e3902c2f2d030a9cb9cfd25e.zip
Support for Servo motor for Arduino. Support for'diag' in c
Diffstat (limited to '2.3-1/src/c/matrixOperations')
-rw-r--r--2.3-1/src/c/matrixOperations/determ/i16determa.c92
-rw-r--r--2.3-1/src/c/matrixOperations/determ/i8determa.c92
-rw-r--r--2.3-1/src/c/matrixOperations/determ/u16determa.c92
-rw-r--r--2.3-1/src/c/matrixOperations/determ/u8determa.c92
-rw-r--r--2.3-1/src/c/matrixOperations/diag/ddiaga.c40
-rw-r--r--2.3-1/src/c/matrixOperations/diag/ddiagexa.c130
-rw-r--r--2.3-1/src/c/matrixOperations/diag/ddiagexs.c53
-rw-r--r--2.3-1/src/c/matrixOperations/diag/ddiagina.c59
-rw-r--r--2.3-1/src/c/matrixOperations/diag/ddiagins.c37
-rw-r--r--2.3-1/src/c/matrixOperations/diag/ddiags.c20
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i16diaga.c40
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i16diagexa.c130
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i16diagexs.c53
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i16diagina.c58
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i16diagins.c37
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i16diags.c20
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i8diaga.c40
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i8diagexa.c130
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i8diagexs.c53
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i8diagina.c58
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i8diagins.c37
-rw-r--r--2.3-1/src/c/matrixOperations/diag/i8diags.c20
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u16diaga.c40
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u16diagexa.c130
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u16diagexs.c53
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u16diagina.c58
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u16diagins.c37
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u16diags.c20
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u8diaga.c40
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u8diagexa.c130
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u8diagexs.c53
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u8diagina.c58
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u8diagins.c37
-rw-r--r--2.3-1/src/c/matrixOperations/diag/u8diags.c20
-rw-r--r--2.3-1/src/c/matrixOperations/division/i16ldivma.c111
-rw-r--r--2.3-1/src/c/matrixOperations/division/i16rdivma.c129
-rw-r--r--2.3-1/src/c/matrixOperations/division/i16rdivv.c24
-rw-r--r--2.3-1/src/c/matrixOperations/division/i8ldivma.c111
-rw-r--r--2.3-1/src/c/matrixOperations/division/i8rdivma.c129
-rw-r--r--2.3-1/src/c/matrixOperations/division/i8rdivv.c24
-rw-r--r--2.3-1/src/c/matrixOperations/division/u16ldivma.c111
-rw-r--r--2.3-1/src/c/matrixOperations/division/u16rdivma.c129
-rw-r--r--2.3-1/src/c/matrixOperations/division/u16rdivv.c24
-rw-r--r--2.3-1/src/c/matrixOperations/division/u8ldivma.c111
-rw-r--r--2.3-1/src/c/matrixOperations/division/u8rdivma.c129
-rw-r--r--2.3-1/src/c/matrixOperations/division/u8rdivv.c24
-rw-r--r--2.3-1/src/c/matrixOperations/includes/diag.h96
-rw-r--r--2.3-1/src/c/matrixOperations/interfaces/int_diag.h87
48 files changed, 3298 insertions, 0 deletions
diff --git a/2.3-1/src/c/matrixOperations/determ/i16determa.c b/2.3-1/src/c/matrixOperations/determ/i16determa.c
new file mode 100644
index 00000000..a1184553
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/determ/i16determa.c
@@ -0,0 +1,92 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 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 <stdlib.h>
+#ifndef WITHOUT_LAPACK
+#include "lapack.h"
+#endif
+#include "determ.h"
+#include "lapack.h"
+
+int16 i16determa(int16 * in, int size){
+#ifndef WITHOUT_LAPACK
+ int i=0, info=0;
+ int16 out=0;
+ int16 *inCopy=NULL;
+ int* tmp=NULL;
+
+ /*Calculation of the determinant*/
+ switch (size){
+ case 2 : out = in[0]*in[3]-in[1]*in[2];
+ break;
+ case 3 : /*regle de Sarrus*/
+ out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7]
+ -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6];
+ break;
+ default :
+
+ /*Copy the input matrix*/
+ inCopy=(int16*)malloc((unsigned int)(size*size)*sizeof(int16));
+ for (i=0;i<size*size;i++) inCopy[i]=in[i];
+
+ tmp=(int*)malloc((unsigned int)size*sizeof(int));
+ dgetrf_(&size, &size, inCopy, &size, tmp, &info);
+ out=1;
+ for (i=0;i<size;i++){
+ if (tmp[i]!=i+1) out=-out;
+ out=inCopy[i*(size+1)]*out;
+ }
+ free(tmp);
+ free(inCopy);
+ break;
+ }
+
+#else
+ int i=0, j=0, k=0;
+ int16 out=0, pivot=0;
+ int16 *inCopy=NULL;
+
+ /*Calculation of the determinant*/
+ switch (size){
+ case 2 : out = in[0]*in[3]-in[1]*in[2];
+ break;
+ case 3 : /*regle de Sarrus*/
+ out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7]
+ -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6];
+ break;
+ default :
+
+ /*Copy the input matrix*/
+ inCopy=malloc((unsigned int)(size*size)*sizeof(int16));
+ for (i=0;i<size*size;i++) inCopy[i]=in[i];
+
+ for (i=0;i<size;i++){
+ for (j=i+1;j<size;j++){
+ pivot = inCopy[i*size+j]/inCopy[i*size+i];
+ for (k=0;k<size-i;k++){
+ inCopy[i*size+j+k*size]-=pivot*inCopy[i*size+i+k*size];
+ }
+ }
+ }
+ out=1;
+ for (i=0;i<size;i++){
+ out *= inCopy[i*size+i];
+ }
+ free(inCopy);
+ break;
+
+ }
+#endif
+
+
+ return out;
+}
diff --git a/2.3-1/src/c/matrixOperations/determ/i8determa.c b/2.3-1/src/c/matrixOperations/determ/i8determa.c
new file mode 100644
index 00000000..9693fe67
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/determ/i8determa.c
@@ -0,0 +1,92 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 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 <stdlib.h>
+#ifndef WITHOUT_LAPACK
+#include "lapack.h"
+#endif
+#include "determ.h"
+#include "lapack.h"
+
+int8 i8determa(int8 * in, int size){
+#ifndef WITHOUT_LAPACK
+ int i=0, info=0;
+ int8 out=0;
+ int8 *inCopy=NULL;
+ int* tmp=NULL;
+
+ /*Calculation of the determinant*/
+ switch (size){
+ case 2 : out = in[0]*in[3]-in[1]*in[2];
+ break;
+ case 3 : /*regle de Sarrus*/
+ out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7]
+ -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6];
+ break;
+ default :
+
+ /*Copy the input matrix*/
+ inCopy=(int8*)malloc((unsigned int)(size*size)*sizeof(int8));
+ for (i=0;i<size*size;i++) inCopy[i]=in[i];
+
+ tmp=(int*)malloc((unsigned int)size*sizeof(int));
+ dgetrf_(&size, &size, inCopy, &size, tmp, &info);
+ out=1;
+ for (i=0;i<size;i++){
+ if (tmp[i]!=i+1) out=-out;
+ out=inCopy[i*(size+1)]*out;
+ }
+ free(tmp);
+ free(inCopy);
+ break;
+ }
+
+#else
+ int i=0, j=0, k=0;
+ int8 out=0, pivot=0;
+ int8 *inCopy=NULL;
+
+ /*Calculation of the determinant*/
+ switch (size){
+ case 2 : out = in[0]*in[3]-in[1]*in[2];
+ break;
+ case 3 : /*regle de Sarrus*/
+ out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7]
+ -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6];
+ break;
+ default :
+
+ /*Copy the input matrix*/
+ inCopy=malloc((unsigned int)(size*size)*sizeof(int8));
+ for (i=0;i<size*size;i++) inCopy[i]=in[i];
+
+ for (i=0;i<size;i++){
+ for (j=i+1;j<size;j++){
+ pivot = inCopy[i*size+j]/inCopy[i*size+i];
+ for (k=0;k<size-i;k++){
+ inCopy[i*size+j+k*size]-=pivot*inCopy[i*size+i+k*size];
+ }
+ }
+ }
+ out=1;
+ for (i=0;i<size;i++){
+ out *= inCopy[i*size+i];
+ }
+ free(inCopy);
+ break;
+
+ }
+#endif
+
+
+ return out;
+}
diff --git a/2.3-1/src/c/matrixOperations/determ/u16determa.c b/2.3-1/src/c/matrixOperations/determ/u16determa.c
new file mode 100644
index 00000000..480d1ed3
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/determ/u16determa.c
@@ -0,0 +1,92 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 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 <stdlib.h>
+#ifndef WITHOUT_LAPACK
+#include "lapack.h"
+#endif
+#include "determ.h"
+#include "lapack.h"
+
+uint16 u16determa(uint16 * in, int size){
+#ifndef WITHOUT_LAPACK
+ int i=0, info=0;
+ uint16 out=0;
+ uint16 *inCopy=NULL;
+ int* tmp=NULL;
+
+ /*Calculation of the determinant*/
+ switch (size){
+ case 2 : out = in[0]*in[3]-in[1]*in[2];
+ break;
+ case 3 : /*regle de Sarrus*/
+ out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7]
+ -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6];
+ break;
+ default :
+
+ /*Copy the input matrix*/
+ inCopy=(uint16*)malloc((unsigned int)(size*size)*sizeof(uint16));
+ for (i=0;i<size*size;i++) inCopy[i]=in[i];
+
+ tmp=(int*)malloc((unsigned int)size*sizeof(int));
+ dgetrf_(&size, &size, inCopy, &size, tmp, &info);
+ out=1;
+ for (i=0;i<size;i++){
+ if (tmp[i]!=i+1) out=-out;
+ out=inCopy[i*(size+1)]*out;
+ }
+ free(tmp);
+ free(inCopy);
+ break;
+ }
+
+#else
+ int i=0, j=0, k=0;
+ uint16 out=0, pivot=0;
+ uint16 *inCopy=NULL;
+
+ /*Calculation of the determinant*/
+ switch (size){
+ case 2 : out = in[0]*in[3]-in[1]*in[2];
+ break;
+ case 3 : /*regle de Sarrus*/
+ out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7]
+ -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6];
+ break;
+ default :
+
+ /*Copy the input matrix*/
+ inCopy=malloc((unsigned int)(size*size)*sizeof(uint16));
+ for (i=0;i<size*size;i++) inCopy[i]=in[i];
+
+ for (i=0;i<size;i++){
+ for (j=i+1;j<size;j++){
+ pivot = inCopy[i*size+j]/inCopy[i*size+i];
+ for (k=0;k<size-i;k++){
+ inCopy[i*size+j+k*size]-=pivot*inCopy[i*size+i+k*size];
+ }
+ }
+ }
+ out=1;
+ for (i=0;i<size;i++){
+ out *= inCopy[i*size+i];
+ }
+ free(inCopy);
+ break;
+
+ }
+#endif
+
+
+ return out;
+}
diff --git a/2.3-1/src/c/matrixOperations/determ/u8determa.c b/2.3-1/src/c/matrixOperations/determ/u8determa.c
new file mode 100644
index 00000000..3fb18d54
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/determ/u8determa.c
@@ -0,0 +1,92 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 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 <stdlib.h>
+#ifndef WITHOUT_LAPACK
+#include "lapack.h"
+#endif
+#include "determ.h"
+#include "lapack.h"
+
+uint8 u8determa(uint8 * in, int size){
+#ifndef WITHOUT_LAPACK
+ int i=0, info=0;
+ uint8 out=0;
+ uint8 *inCopy=NULL;
+ int* tmp=NULL;
+
+ /*Calculation of the determinant*/
+ switch (size){
+ case 2 : out = in[0]*in[3]-in[1]*in[2];
+ break;
+ case 3 : /*regle de Sarrus*/
+ out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7]
+ -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6];
+ break;
+ default :
+
+ /*Copy the input matrix*/
+ inCopy=(uint8*)malloc((unsigned int)(size*size)*sizeof(uint8));
+ for (i=0;i<size*size;i++) inCopy[i]=in[i];
+
+ tmp=(int*)malloc((unsigned int)size*sizeof(int));
+ dgetrf_(&size, &size, inCopy, &size, tmp, &info);
+ out=1;
+ for (i=0;i<size;i++){
+ if (tmp[i]!=i+1) out=-out;
+ out=inCopy[i*(size+1)]*out;
+ }
+ free(tmp);
+ free(inCopy);
+ break;
+ }
+
+#else
+ int i=0, j=0, k=0;
+ uint8 out=0, pivot=0;
+ uint8 *inCopy=NULL;
+
+ /*Calculation of the determinant*/
+ switch (size){
+ case 2 : out = in[0]*in[3]-in[1]*in[2];
+ break;
+ case 3 : /*regle de Sarrus*/
+ out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7]
+ -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6];
+ break;
+ default :
+
+ /*Copy the input matrix*/
+ inCopy=malloc((unsigned int)(size*size)*sizeof(uint8));
+ for (i=0;i<size*size;i++) inCopy[i]=in[i];
+
+ for (i=0;i<size;i++){
+ for (j=i+1;j<size;j++){
+ pivot = inCopy[i*size+j]/inCopy[i*size+i];
+ for (k=0;k<size-i;k++){
+ inCopy[i*size+j+k*size]-=pivot*inCopy[i*size+i+k*size];
+ }
+ }
+ }
+ out=1;
+ for (i=0;i<size;i++){
+ out *= inCopy[i*size+i];
+ }
+ free(inCopy);
+ break;
+
+ }
+#endif
+
+
+ return out;
+}
diff --git a/2.3-1/src/c/matrixOperations/diag/ddiaga.c b/2.3-1/src/c/matrixOperations/diag/ddiaga.c
new file mode 100644
index 00000000..26363ef9
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/ddiaga.c
@@ -0,0 +1,40 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void ddiaga(double in, int size,int insert_post,double *out)
+{
+
+ int i;
+
+ for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+
+ out[abs(insert_post)] = in;
+
+ }
+ else
+ {
+
+ out[(size + insert_post)*insert_post] = in;
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/ddiagexa.c b/2.3-1/src/c/matrixOperations/diag/ddiagexa.c
new file mode 100644
index 00000000..191c1311
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/ddiagexa.c
@@ -0,0 +1,130 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void ddiagexa(double *in, int _row,int _column,int extract_post,double *out)
+{
+
+
+ int j;
+ if(_row == _column)
+ {
+ if(extract_post <= 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+ out[j] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+ else
+ {
+ for ( j = extract_post ; j < _column ; j++ )
+ {
+
+
+ out[j-extract_post] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+
+ }
+ else if(_row > _column)
+ {
+
+ if(extract_post >=0)
+ {
+
+ for(j = extract_post; j < _column;j++)
+ {
+
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+
+ }
+ else
+ {
+
+ if((abs(extract_post) <= (_row - _column)))
+ {
+ for(j = 0; j < _column ; j++)
+ {
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+ }
+ else
+ {
+
+ for(j=0; j < (_row + extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+
+
+
+ }
+
+ }
+
+ }
+ else if (_row < _column)
+ {
+
+ if(extract_post > 0)
+ {
+ if((extract_post <= (_column - _row)))
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+ else
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+
+ }
+ else
+ {
+
+
+ for(j=0;j < (_row+extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+
+
+ }
+
+
+
+ }
+
+
+ }
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/ddiagexs.c b/2.3-1/src/c/matrixOperations/diag/ddiagexs.c
new file mode 100644
index 00000000..fb007b52
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/ddiagexs.c
@@ -0,0 +1,53 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+double ddiagexs(double *in, int _row,int _column,int extract_post)
+{
+
+ if(_row == _column)
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1] ;
+ }
+ else
+ {
+
+ return in[(_row)*(_row-1)] ;
+
+ }
+ }
+
+ else
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1];
+
+ }
+ else
+ {
+ return in[(_row)*(_column-1)];
+
+ }
+
+
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/ddiagina.c b/2.3-1/src/c/matrixOperations/diag/ddiagina.c
new file mode 100644
index 00000000..c4093b2d
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/ddiagina.c
@@ -0,0 +1,59 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void ddiagina(double *in, int _row,int _column,int insert_post,double *out)
+{
+
+ int i, j;
+ if(_row == 1)
+ {
+ _column = _column;
+
+ }
+ else
+ {
+ _column = _row;
+
+ }
+
+ for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+
+ out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j];
+ }
+
+ }
+ else
+ {
+ for ( j = insert_post ; j < _column+insert_post ; j++ )
+ {
+
+
+ out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ;
+
+ }
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/ddiagins.c b/2.3-1/src/c/matrixOperations/diag/ddiagins.c
new file mode 100644
index 00000000..d1fc527a
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/ddiagins.c
@@ -0,0 +1,37 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void ddiagins(double *in, int size,double *out)
+{
+
+ int i, j;
+ for ( i = 0 ; i < size ; i++ )
+ {
+ for ( j = 0 ; j < size ; j++ )
+ {
+ if(i==j)
+ {
+ out[(size+1)*i] = in[i] ;
+ /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix
+ i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */
+
+
+ }
+
+ }
+ }
+
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/ddiags.c b/2.3-1/src/c/matrixOperations/diag/ddiags.c
new file mode 100644
index 00000000..b43e5d63
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/ddiags.c
@@ -0,0 +1,20 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+double ddiags(double in)
+{
+
+ return in;
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i16diaga.c b/2.3-1/src/c/matrixOperations/diag/i16diaga.c
new file mode 100644
index 00000000..29f92907
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i16diaga.c
@@ -0,0 +1,40 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void i16diaga(int16 in, int size,int insert_post,int16 *out)
+{
+
+ int i;
+
+ for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+
+ out[abs(insert_post)] = in;
+
+ }
+ else
+ {
+
+ out[(size + insert_post)*insert_post] = in;
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i16diagexa.c b/2.3-1/src/c/matrixOperations/diag/i16diagexa.c
new file mode 100644
index 00000000..7e85c916
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i16diagexa.c
@@ -0,0 +1,130 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void i16diagexa(int16 *in, int _row,int _column,int extract_post,int16 *out)
+{
+
+
+ int j;
+ if(_row == _column)
+ {
+ if(extract_post <= 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+ out[j] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+ else
+ {
+ for ( j = extract_post ; j < _column ; j++ )
+ {
+
+
+ out[j-extract_post] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+
+ }
+ else if(_row > _column)
+ {
+
+ if(extract_post >=0)
+ {
+
+ for(j = extract_post; j < _column;j++)
+ {
+
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+
+ }
+ else
+ {
+
+ if((abs(extract_post) <= (_row - _column)))
+ {
+ for(j = 0; j < _column ; j++)
+ {
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+ }
+ else
+ {
+
+ for(j=0; j < (_row + extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+
+
+
+ }
+
+ }
+
+ }
+ else if (_row < _column)
+ {
+
+ if(extract_post > 0)
+ {
+ if((extract_post <= (_column - _row)))
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+ else
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+
+ }
+ else
+ {
+
+
+ for(j=0;j < (_row+extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+
+
+ }
+
+
+
+ }
+
+
+ }
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i16diagexs.c b/2.3-1/src/c/matrixOperations/diag/i16diagexs.c
new file mode 100644
index 00000000..87536ce1
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i16diagexs.c
@@ -0,0 +1,53 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+int16 i16diagexs(int16 *in, int _row,int _column,int extract_post)
+{
+
+ if(_row == _column)
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1] ;
+ }
+ else
+ {
+
+ return in[(_row)*(_row-1)] ;
+
+ }
+ }
+
+ else
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1];
+
+ }
+ else
+ {
+ return in[(_row)*(_column-1)];
+
+ }
+
+
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i16diagina.c b/2.3-1/src/c/matrixOperations/diag/i16diagina.c
new file mode 100644
index 00000000..518f627c
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i16diagina.c
@@ -0,0 +1,58 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void i16diagina(int16 *in, int _row,int _column,int insert_post,int16 *out)
+{
+ int i, j;
+ if(_row == 1)
+ {
+ _column = _column;
+
+ }
+ else
+ {
+ _column = _row;
+
+ }
+
+ for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+
+ out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j];
+ }
+
+ }
+ else
+ {
+ for ( j = insert_post ; j < _column+insert_post ; j++ )
+ {
+
+
+ out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ;
+
+ }
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i16diagins.c b/2.3-1/src/c/matrixOperations/diag/i16diagins.c
new file mode 100644
index 00000000..f0d46eb9
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i16diagins.c
@@ -0,0 +1,37 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void i16diagins(int16 *in, int size,int16 *out)
+{
+
+ int i, j;
+ for ( i = 0 ; i < size ; i++ )
+ {
+ for ( j = 0 ; j < size ; j++ )
+ {
+ if(i==j)
+ {
+ out[(size+1)*i] = in[i] ;
+ /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix
+ i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */
+
+
+ }
+
+ }
+ }
+
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i16diags.c b/2.3-1/src/c/matrixOperations/diag/i16diags.c
new file mode 100644
index 00000000..b08657f5
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i16diags.c
@@ -0,0 +1,20 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+int16 i16diags(int16 in)
+{
+
+ return in;
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i8diaga.c b/2.3-1/src/c/matrixOperations/diag/i8diaga.c
new file mode 100644
index 00000000..c41ec9df
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i8diaga.c
@@ -0,0 +1,40 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void i8diaga(int8 in, int size,int insert_post,int8 *out)
+{
+
+ int i;
+
+ for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+
+ out[abs(insert_post)] = in;
+
+ }
+ else
+ {
+
+ out[(size + insert_post)*insert_post] = in;
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i8diagexa.c b/2.3-1/src/c/matrixOperations/diag/i8diagexa.c
new file mode 100644
index 00000000..56fab854
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i8diagexa.c
@@ -0,0 +1,130 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void i8diagexa(int8 *in, int _row,int _column,int extract_post,int8 *out)
+{
+
+
+ int j;
+ if(_row == _column)
+ {
+ if(extract_post <= 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+ out[j] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+ else
+ {
+ for ( j = extract_post ; j < _column ; j++ )
+ {
+
+
+ out[j-extract_post] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+
+ }
+ else if(_row > _column)
+ {
+
+ if(extract_post >=0)
+ {
+
+ for(j = extract_post; j < _column;j++)
+ {
+
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+
+ }
+ else
+ {
+
+ if((abs(extract_post) <= (_row - _column)))
+ {
+ for(j = 0; j < _column ; j++)
+ {
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+ }
+ else
+ {
+
+ for(j=0; j < (_row + extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+
+
+
+ }
+
+ }
+
+ }
+ else if (_row < _column)
+ {
+
+ if(extract_post > 0)
+ {
+ if((extract_post <= (_column - _row)))
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+ else
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+
+ }
+ else
+ {
+
+
+ for(j=0;j < (_row+extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+
+
+ }
+
+
+
+ }
+
+
+ }
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i8diagexs.c b/2.3-1/src/c/matrixOperations/diag/i8diagexs.c
new file mode 100644
index 00000000..6aa76049
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i8diagexs.c
@@ -0,0 +1,53 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+int8 i8diagexs(int8 *in, int _row,int _column,int extract_post)
+{
+
+ if(_row == _column)
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1] ;
+ }
+ else
+ {
+
+ return in[(_row)*(_row-1)] ;
+
+ }
+ }
+
+ else
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1];
+
+ }
+ else
+ {
+ return in[(_row)*(_column-1)];
+
+ }
+
+
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i8diagina.c b/2.3-1/src/c/matrixOperations/diag/i8diagina.c
new file mode 100644
index 00000000..77a7e074
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i8diagina.c
@@ -0,0 +1,58 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void i8diagina(int8 *in, int _row,int _column,int insert_post,int8 *out)
+{
+ int i, j;
+ if(_row == 1)
+ {
+ _column = _column;
+
+ }
+ else
+ {
+ _column = _row;
+
+ }
+
+ for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+
+ out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j];
+ }
+
+ }
+ else
+ {
+ for ( j = insert_post ; j < _column+insert_post ; j++ )
+ {
+
+
+ out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ;
+
+ }
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i8diagins.c b/2.3-1/src/c/matrixOperations/diag/i8diagins.c
new file mode 100644
index 00000000..adb7eb96
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i8diagins.c
@@ -0,0 +1,37 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void i8diagins(int8 *in, int size,int8 *out)
+{
+
+ int i, j;
+ for ( i = 0 ; i < size ; i++ )
+ {
+ for ( j = 0 ; j < size ; j++ )
+ {
+ if(i==j)
+ {
+ out[(size+1)*i] = in[i] ;
+ /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix
+ i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */
+
+
+ }
+
+ }
+ }
+
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/i8diags.c b/2.3-1/src/c/matrixOperations/diag/i8diags.c
new file mode 100644
index 00000000..d4e44894
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/i8diags.c
@@ -0,0 +1,20 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+int8 i8diags(int8 in)
+{
+
+ return in;
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u16diaga.c b/2.3-1/src/c/matrixOperations/diag/u16diaga.c
new file mode 100644
index 00000000..90a10536
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u16diaga.c
@@ -0,0 +1,40 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void u16diaga(uint16 in, int size,int insert_post,uint16 *out)
+{
+
+ int i;
+
+ for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+
+ out[abs(insert_post)] = in;
+
+ }
+ else
+ {
+
+ out[(size + insert_post)*insert_post] = in;
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u16diagexa.c b/2.3-1/src/c/matrixOperations/diag/u16diagexa.c
new file mode 100644
index 00000000..da2088c5
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u16diagexa.c
@@ -0,0 +1,130 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void u16diagexa(uint16 *in, int _row,int _column,int extract_post,uint16 *out)
+{
+
+
+ int j;
+ if(_row == _column)
+ {
+ if(extract_post <= 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+ out[j] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+ else
+ {
+ for ( j = extract_post ; j < _column ; j++ )
+ {
+
+
+ out[j-extract_post] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+
+ }
+ else if(_row > _column)
+ {
+
+ if(extract_post >=0)
+ {
+
+ for(j = extract_post; j < _column;j++)
+ {
+
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+
+ }
+ else
+ {
+
+ if((abs(extract_post) <= (_row - _column)))
+ {
+ for(j = 0; j < _column ; j++)
+ {
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+ }
+ else
+ {
+
+ for(j=0; j < (_row + extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+
+
+
+ }
+
+ }
+
+ }
+ else if (_row < _column)
+ {
+
+ if(extract_post > 0)
+ {
+ if((extract_post <= (_column - _row)))
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+ else
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+
+ }
+ else
+ {
+
+
+ for(j=0;j < (_row+extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+
+
+ }
+
+
+
+ }
+
+
+ }
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u16diagexs.c b/2.3-1/src/c/matrixOperations/diag/u16diagexs.c
new file mode 100644
index 00000000..c32849e6
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u16diagexs.c
@@ -0,0 +1,53 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+uint16 u16diagexs(uint16 *in, int _row,int _column,int extract_post)
+{
+
+ if(_row == _column)
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1] ;
+ }
+ else
+ {
+
+ return in[(_row)*(_row-1)] ;
+
+ }
+ }
+
+ else
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1];
+
+ }
+ else
+ {
+ return in[(_row)*(_column-1)];
+
+ }
+
+
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u16diagina.c b/2.3-1/src/c/matrixOperations/diag/u16diagina.c
new file mode 100644
index 00000000..f5dc6f99
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u16diagina.c
@@ -0,0 +1,58 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void u16diagina(uint16 *in, int _row,int _column,int insert_post,uint16 *out)
+{
+ int i, j;
+ if(_row == 1)
+ {
+ _column = _column;
+
+ }
+ else
+ {
+ _column = _row;
+
+ }
+
+ for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+
+ out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j];
+ }
+
+ }
+ else
+ {
+ for ( j = insert_post ; j < _column+insert_post ; j++ )
+ {
+
+
+ out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ;
+
+ }
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u16diagins.c b/2.3-1/src/c/matrixOperations/diag/u16diagins.c
new file mode 100644
index 00000000..84cfcb29
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u16diagins.c
@@ -0,0 +1,37 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void u16diagins(uint16 *in, int size,uint16 *out)
+{
+
+ int i, j;
+ for ( i = 0 ; i < size ; i++ )
+ {
+ for ( j = 0 ; j < size ; j++ )
+ {
+ if(i==j)
+ {
+ out[(size+1)*i] = in[i] ;
+ /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix
+ i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */
+
+
+ }
+
+ }
+ }
+
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u16diags.c b/2.3-1/src/c/matrixOperations/diag/u16diags.c
new file mode 100644
index 00000000..0f463b09
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u16diags.c
@@ -0,0 +1,20 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+uint16 u16diags(uint16 in)
+{
+
+ return in;
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u8diaga.c b/2.3-1/src/c/matrixOperations/diag/u8diaga.c
new file mode 100644
index 00000000..05a03ba2
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u8diaga.c
@@ -0,0 +1,40 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void u8diaga(uint8 in, int size,int insert_post,uint8 *out)
+{
+
+ int i;
+
+ for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+
+ out[abs(insert_post)] = in;
+
+ }
+ else
+ {
+
+ out[(size + insert_post)*insert_post] = in;
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u8diagexa.c b/2.3-1/src/c/matrixOperations/diag/u8diagexa.c
new file mode 100644
index 00000000..258e10b0
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u8diagexa.c
@@ -0,0 +1,130 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void u8diagexa(uint8 *in, int _row,int _column,int extract_post,uint8 *out)
+{
+
+
+ int j;
+ if(_row == _column)
+ {
+ if(extract_post <= 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+ out[j] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+ else
+ {
+ for ( j = extract_post ; j < _column ; j++ )
+ {
+
+
+ out[j-extract_post] = in[((_column+1)*j)-extract_post] ;
+
+ }
+ }
+
+ }
+ else if(_row > _column)
+ {
+
+ if(extract_post >=0)
+ {
+
+ for(j = extract_post; j < _column;j++)
+ {
+
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+
+ }
+ else
+ {
+
+ if((abs(extract_post) <= (_row - _column)))
+ {
+ for(j = 0; j < _column ; j++)
+ {
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+ }
+ else
+ {
+
+ for(j=0; j < (_row + extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+ }
+
+
+
+ }
+
+ }
+
+ }
+ else if (_row < _column)
+ {
+
+ if(extract_post > 0)
+ {
+ if((extract_post <= (_column - _row)))
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+ else
+ {
+ for(j=extract_post;j < _column;j++)
+ {
+ out[j-extract_post] = in[((_row+1)*j)-extract_post];
+ }
+
+ }
+
+ }
+ else
+ {
+
+
+ for(j=0;j < (_row+extract_post);j++)
+ {
+
+ out[j] = in[((_row+1)*j)-extract_post];
+
+
+
+ }
+
+
+
+ }
+
+
+ }
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u8diagexs.c b/2.3-1/src/c/matrixOperations/diag/u8diagexs.c
new file mode 100644
index 00000000..fbb2ef3f
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u8diagexs.c
@@ -0,0 +1,53 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+uint8 u8diagexs(uint8 *in, int _row,int _column,int extract_post)
+{
+
+ if(_row == _column)
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1] ;
+ }
+ else
+ {
+
+ return in[(_row)*(_row-1)] ;
+
+ }
+ }
+
+ else
+ {
+
+ if(extract_post < 0)
+ {
+
+ return in[_row-1];
+
+ }
+ else
+ {
+ return in[(_row)*(_column-1)];
+
+ }
+
+
+
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u8diagina.c b/2.3-1/src/c/matrixOperations/diag/u8diagina.c
new file mode 100644
index 00000000..bea24655
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u8diagina.c
@@ -0,0 +1,58 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+#include<stdlib.h> // Used for Absolute value of insert_post
+void u8diagina(uint8 *in, int _row,int _column,int insert_post,uint8 *out)
+{
+ int i, j;
+ if(_row == 1)
+ {
+ _column = _column;
+
+ }
+ else
+ {
+ _column = _row;
+
+ }
+
+ for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++)
+ {
+ out[i] = 0;
+
+ }
+
+ if(insert_post < 0)
+ {
+ for ( j = 0 ; j < _column ; j++ )
+ {
+
+
+
+ out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j];
+ }
+
+ }
+ else
+ {
+ for ( j = insert_post ; j < _column+insert_post ; j++ )
+ {
+
+
+ out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ;
+
+ }
+ }
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u8diagins.c b/2.3-1/src/c/matrixOperations/diag/u8diagins.c
new file mode 100644
index 00000000..f2765952
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u8diagins.c
@@ -0,0 +1,37 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+void u8diagins(uint8 *in, int size,uint8 *out)
+{
+
+ int i, j;
+ for ( i = 0 ; i < size ; i++ )
+ {
+ for ( j = 0 ; j < size ; j++ )
+ {
+ if(i==j)
+ {
+ out[(size+1)*i] = in[i] ;
+ /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix
+ i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */
+
+
+ }
+
+ }
+ }
+
+
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/diag/u8diags.c b/2.3-1/src/c/matrixOperations/diag/u8diags.c
new file mode 100644
index 00000000..97d2e515
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/diag/u8diags.c
@@ -0,0 +1,20 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 "diag.h"
+uint8 u8diags(uint8 in)
+{
+
+ return in;
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/division/i16ldivma.c b/2.3-1/src/c/matrixOperations/division/i16ldivma.c
new file mode 100644
index 00000000..e5a134d0
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/i16ldivma.c
@@ -0,0 +1,111 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include "matrixDivision.h"
+#include "lapack.h"
+
+void i16ldivma (int16* in1, int lines1, int columns1 ,
+ int16* in2, int lines2, int columns2 ,
+ int16* out ){
+
+
+ char cNorm = 0;
+ int iExit = 0;
+
+ /*temporary variables*/
+ int iWork = 0;
+ int iInfo = 0;
+ int iMax = 0;
+ int16 dblRcond = 0;
+
+ int16 dblEps = 0;
+ int16 dblAnorm = 0;
+
+ int16 *pAf = NULL;
+ int16 *pXb = NULL;
+ int16 *pDwork = NULL;
+
+ int *pRank = NULL;
+ int *pIpiv = NULL;
+ int *pJpvt = NULL;
+ int *pIwork = NULL;
+
+ iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2));
+
+
+ lines2 = 0 ;
+
+ /* Array allocations*/
+ pAf = (int16*)malloc(sizeof(int16) * (unsigned int) lines1 * (unsigned int) columns1);
+ pXb = (int16*)malloc(sizeof(int16) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2);
+
+ pRank = (int*)malloc(sizeof(int));
+ pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+ pJpvt = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+ pIwork = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+
+
+
+ cNorm = '1';
+ pDwork = (int16*)malloc(sizeof(int16) *(unsigned int)iWork);
+ dblEps = getRelativeMachinePrecision() ;
+
+ dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork);
+ if(lines1 == columns1)
+ {
+ cNorm = 'F';
+ dlacpy_(&cNorm, &columns1, &columns1, in1, &columns1, pAf, &columns1);
+ dgetrf_(&columns1, &columns1, pAf, &columns1, pIpiv, &iInfo);
+ if(iInfo == 0)
+ {
+ cNorm = '1';
+ C2F(dgecon)(&cNorm, &columns1, pAf, &columns1, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo);
+ if(dblRcond > sqrt(dblEps))
+ {
+ cNorm = 'N';
+ C2F(dgetrs)(&cNorm, &columns1, &columns2, pAf, &columns1, pIpiv, in2, &columns1, &iInfo);
+ cNorm = 'F';
+ C2F(dlacpy)(&cNorm, &columns1, &columns2, in2, &columns1, out, &columns1);
+ iExit = 1;
+ }
+ }
+
+ }
+
+ if(iExit == 0)
+ {
+ dblRcond = sqrt(dblEps);
+ cNorm = 'F';
+ iMax = max(lines1, columns1);
+ C2F(dlacpy)(&cNorm, &lines1, &columns2, in2, &lines1, pXb, &iMax);
+ memset(pJpvt, 0x00,(unsigned int) sizeof(int) * (unsigned int) columns1);
+ C2F(dgelsy)( &lines1, &columns1, &columns2, in1, &lines1, pXb, &iMax,
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+
+ if(iInfo == 0)
+ {
+
+ cNorm = 'F';
+ C2F(dlacpy)(&cNorm, &columns1, &columns2, pXb, &iMax, out, &columns1);
+ }
+ }
+
+ free(pAf);
+ free(pXb);
+ free(pRank);
+ free(pIpiv);
+ free(pJpvt);
+ free(pIwork);
+ free(pDwork);
+}
diff --git a/2.3-1/src/c/matrixOperations/division/i16rdivma.c b/2.3-1/src/c/matrixOperations/division/i16rdivma.c
new file mode 100644
index 00000000..21f6cc94
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/i16rdivma.c
@@ -0,0 +1,129 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include "matrixDivision.h"
+#include "lapack.h"
+
+void i16rdivma ( int16 * in1, int lines1, int columns1,
+ int16 * in2, int lines2, int columns2,
+ int16 * out){
+
+ char cNorm = 0;
+ int iExit = 0;
+
+ /*temporary variables*/
+ int iWork = 0;
+ int iInfo = 0;
+ int iMax = 0;
+ int16 dblRcond = 0;
+
+ int16 dblEps = 0;
+ int16 dblAnorm = 0;
+
+ int16 *pAf = NULL;
+ int16 *pAt = NULL;
+ int16 *pBt = NULL;
+ int16 *pDwork = NULL;
+
+ int *pRank = NULL;
+ int *pIpiv = NULL;
+ int *pJpvt = NULL;
+ int *pIwork = NULL;
+
+ iWork = max(4 * columns2, max(min(lines2, columns2) + 3 * lines2 + 1, 2 * min(lines2, columns2) + lines1));
+
+
+ /* Array allocations*/
+ pAf = (int16*)malloc(sizeof(int16) * (unsigned int)columns2 * (unsigned int)lines2);
+ pAt = (int16*)malloc(sizeof(int16) * (unsigned int)columns2 *(unsigned int) lines2);
+ pBt = (int16*)malloc(sizeof(int16) * (unsigned int)max(lines2,columns2) * (unsigned int)lines1);
+
+ pRank = (int*)malloc(sizeof(int));
+ pIpiv = (int*)malloc(sizeof(int) * (unsigned int)columns2);
+ pJpvt = (int*)malloc(sizeof(int) * (unsigned int)lines2);
+ pIwork = (int*)malloc(sizeof(int) * (unsigned int)columns2);
+
+
+ cNorm = '1';
+ pDwork = (int16*)malloc(sizeof(int16) * (unsigned int)iWork);
+ dblEps = getRelativeMachinePrecision() ;
+ dblAnorm = dlange_(&cNorm, &lines2, &columns1, in2, &lines2, pDwork);
+
+ /*tranpose A and B*/
+
+ dtransposea(in2, lines2, columns2, pAt);
+ dtransposea(in1, lines1, columns2, pBt);
+
+ if(lines2 == columns2)
+ {
+ cNorm = 'F';
+ dlacpy_(&cNorm, &columns2, &columns2, pAt, &columns2, pAf, &columns2);
+ dgetrf_(&columns2, &columns2, pAf, &columns2, pIpiv, &iInfo);
+ if(iInfo == 0)
+ {
+ cNorm = '1';
+ dgecon_(&cNorm, &columns2, pAf, &columns2, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo);
+ if(dblRcond > sqrt(dblEps))
+ {
+ cNorm = 'N';
+ dgetrs_(&cNorm, &columns2, &lines1, pAf, &columns2, pIpiv, pBt, &columns2, &iInfo);
+ dtransposea(pBt, columns2, lines1, out);
+ iExit = 1;
+ }
+ }
+
+ }
+
+ if(iExit == 0)
+ {
+ dblRcond = sqrt(dblEps);
+ cNorm = 'F';
+ iMax = max(lines2, columns2);
+ memset(pJpvt, 0x00, (unsigned int)sizeof(int) * (unsigned int)lines2);
+ dgelsy_(&columns2, &lines2, &lines1, pAt, &columns2, pBt, &iMax,
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+
+ if(iInfo == 0)
+ {
+
+
+ /* TransposeRealMatrix(pBt, lines1, lines2, out, Max(lines1,columns1), lines2);*/
+
+ /*Mega caca de la mort qui tue des ours a mains nues
+ mais je ne sais pas comment le rendre "beau" :(*/
+ {
+ int i,j,ij,ji;
+ for(j = 0 ; j < lines2 ; j++)
+ {
+ for(i = 0 ; i < lines1 ; i++)
+ {
+ ij = i + j * lines1;
+ ji = j + i * max(lines2, columns2);
+ out[ij] = pBt[ji];
+ }
+ }
+ }
+ }
+ }
+
+ free(pAf);
+ free(pAt);
+ free(pBt);
+ free(pRank);
+ free(pIpiv);
+ free(pJpvt);
+ free(pIwork);
+ free(pDwork);
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/division/i16rdivv.c b/2.3-1/src/c/matrixOperations/division/i16rdivv.c
new file mode 100644
index 00000000..72d3bd60
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/i16rdivv.c
@@ -0,0 +1,24 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - INRIA - Allan SIMON
+ *
+ * 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 "matrixDivision.h"
+
+int16 i16rdivv(int16 *in1, int16 *in2, int size){
+
+ int16 out[1] = { 0.0} ;
+ i16rdivma ( in1,1 ,size ,in2 , 1 , size , out );
+
+ return out[0] ;
+}
+
+
diff --git a/2.3-1/src/c/matrixOperations/division/i8ldivma.c b/2.3-1/src/c/matrixOperations/division/i8ldivma.c
new file mode 100644
index 00000000..85271c6b
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/i8ldivma.c
@@ -0,0 +1,111 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include "matrixDivision.h"
+#include "lapack.h"
+
+void i8ldivma (int8* in1, int lines1, int columns1 ,
+ int8* in2, int lines2, int columns2 ,
+ int8* out ){
+
+
+ char cNorm = 0;
+ int iExit = 0;
+
+ /*temporary variables*/
+ int iWork = 0;
+ int iInfo = 0;
+ int iMax = 0;
+ int8 dblRcond = 0;
+
+ int8 dblEps = 0;
+ int8 dblAnorm = 0;
+
+ int8 *pAf = NULL;
+ int8 *pXb = NULL;
+ int8 *pDwork = NULL;
+
+ int *pRank = NULL;
+ int *pIpiv = NULL;
+ int *pJpvt = NULL;
+ int *pIwork = NULL;
+
+ iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2));
+
+
+ lines2 = 0 ;
+
+ /* Array allocations*/
+ pAf = (int8*)malloc(sizeof(int8) * (unsigned int) lines1 * (unsigned int) columns1);
+ pXb = (int8*)malloc(sizeof(int8) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2);
+
+ pRank = (int*)malloc(sizeof(int));
+ pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+ pJpvt = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+ pIwork = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+
+
+
+ cNorm = '1';
+ pDwork = (int8*)malloc(sizeof(int8) *(unsigned int)iWork);
+ dblEps = getRelativeMachinePrecision() ;
+
+ dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork);
+ if(lines1 == columns1)
+ {
+ cNorm = 'F';
+ dlacpy_(&cNorm, &columns1, &columns1, in1, &columns1, pAf, &columns1);
+ dgetrf_(&columns1, &columns1, pAf, &columns1, pIpiv, &iInfo);
+ if(iInfo == 0)
+ {
+ cNorm = '1';
+ C2F(dgecon)(&cNorm, &columns1, pAf, &columns1, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo);
+ if(dblRcond > sqrt(dblEps))
+ {
+ cNorm = 'N';
+ C2F(dgetrs)(&cNorm, &columns1, &columns2, pAf, &columns1, pIpiv, in2, &columns1, &iInfo);
+ cNorm = 'F';
+ C2F(dlacpy)(&cNorm, &columns1, &columns2, in2, &columns1, out, &columns1);
+ iExit = 1;
+ }
+ }
+
+ }
+
+ if(iExit == 0)
+ {
+ dblRcond = sqrt(dblEps);
+ cNorm = 'F';
+ iMax = max(lines1, columns1);
+ C2F(dlacpy)(&cNorm, &lines1, &columns2, in2, &lines1, pXb, &iMax);
+ memset(pJpvt, 0x00,(unsigned int) sizeof(int) * (unsigned int) columns1);
+ C2F(dgelsy)( &lines1, &columns1, &columns2, in1, &lines1, pXb, &iMax,
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+
+ if(iInfo == 0)
+ {
+
+ cNorm = 'F';
+ C2F(dlacpy)(&cNorm, &columns1, &columns2, pXb, &iMax, out, &columns1);
+ }
+ }
+
+ free(pAf);
+ free(pXb);
+ free(pRank);
+ free(pIpiv);
+ free(pJpvt);
+ free(pIwork);
+ free(pDwork);
+}
diff --git a/2.3-1/src/c/matrixOperations/division/i8rdivma.c b/2.3-1/src/c/matrixOperations/division/i8rdivma.c
new file mode 100644
index 00000000..5095d9c6
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/i8rdivma.c
@@ -0,0 +1,129 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include "matrixDivision.h"
+#include "lapack.h"
+
+void i8rdivma ( int8 * in1, int lines1, int columns1,
+ int8 * in2, int lines2, int columns2,
+ int8 * out){
+
+ char cNorm = 0;
+ int iExit = 0;
+
+ /*temporary variables*/
+ int iWork = 0;
+ int iInfo = 0;
+ int iMax = 0;
+ int8 dblRcond = 0;
+
+ int8 dblEps = 0;
+ int8 dblAnorm = 0;
+
+ int8 *pAf = NULL;
+ int8 *pAt = NULL;
+ int8 *pBt = NULL;
+ int8 *pDwork = NULL;
+
+ int *pRank = NULL;
+ int *pIpiv = NULL;
+ int *pJpvt = NULL;
+ int *pIwork = NULL;
+
+ iWork = max(4 * columns2, max(min(lines2, columns2) + 3 * lines2 + 1, 2 * min(lines2, columns2) + lines1));
+
+
+ /* Array allocations*/
+ pAf = (int8*)malloc(sizeof(int8) * (unsigned int)columns2 * (unsigned int)lines2);
+ pAt = (int8*)malloc(sizeof(int8) * (unsigned int)columns2 *(unsigned int) lines2);
+ pBt = (int8*)malloc(sizeof(int8) * (unsigned int)max(lines2,columns2) * (unsigned int)lines1);
+
+ pRank = (int*)malloc(sizeof(int));
+ pIpiv = (int*)malloc(sizeof(int) * (unsigned int)columns2);
+ pJpvt = (int*)malloc(sizeof(int) * (unsigned int)lines2);
+ pIwork = (int*)malloc(sizeof(int) * (unsigned int)columns2);
+
+
+ cNorm = '1';
+ pDwork = (int8*)malloc(sizeof(int8) * (unsigned int)iWork);
+ dblEps = getRelativeMachinePrecision() ;
+ dblAnorm = dlange_(&cNorm, &lines2, &columns1, in2, &lines2, pDwork);
+
+ /*tranpose A and B*/
+
+ dtransposea(in2, lines2, columns2, pAt);
+ dtransposea(in1, lines1, columns2, pBt);
+
+ if(lines2 == columns2)
+ {
+ cNorm = 'F';
+ dlacpy_(&cNorm, &columns2, &columns2, pAt, &columns2, pAf, &columns2);
+ dgetrf_(&columns2, &columns2, pAf, &columns2, pIpiv, &iInfo);
+ if(iInfo == 0)
+ {
+ cNorm = '1';
+ dgecon_(&cNorm, &columns2, pAf, &columns2, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo);
+ if(dblRcond > sqrt(dblEps))
+ {
+ cNorm = 'N';
+ dgetrs_(&cNorm, &columns2, &lines1, pAf, &columns2, pIpiv, pBt, &columns2, &iInfo);
+ dtransposea(pBt, columns2, lines1, out);
+ iExit = 1;
+ }
+ }
+
+ }
+
+ if(iExit == 0)
+ {
+ dblRcond = sqrt(dblEps);
+ cNorm = 'F';
+ iMax = max(lines2, columns2);
+ memset(pJpvt, 0x00, (unsigned int)sizeof(int) * (unsigned int)lines2);
+ dgelsy_(&columns2, &lines2, &lines1, pAt, &columns2, pBt, &iMax,
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+
+ if(iInfo == 0)
+ {
+
+
+ /* TransposeRealMatrix(pBt, lines1, lines2, out, Max(lines1,columns1), lines2);*/
+
+ /*Mega caca de la mort qui tue des ours a mains nues
+ mais je ne sais pas comment le rendre "beau" :(*/
+ {
+ int i,j,ij,ji;
+ for(j = 0 ; j < lines2 ; j++)
+ {
+ for(i = 0 ; i < lines1 ; i++)
+ {
+ ij = i + j * lines1;
+ ji = j + i * max(lines2, columns2);
+ out[ij] = pBt[ji];
+ }
+ }
+ }
+ }
+ }
+
+ free(pAf);
+ free(pAt);
+ free(pBt);
+ free(pRank);
+ free(pIpiv);
+ free(pJpvt);
+ free(pIwork);
+ free(pDwork);
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/division/i8rdivv.c b/2.3-1/src/c/matrixOperations/division/i8rdivv.c
new file mode 100644
index 00000000..04c6c49e
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/i8rdivv.c
@@ -0,0 +1,24 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - INRIA - Allan SIMON
+ *
+ * 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 "matrixDivision.h"
+
+int8 i8rdivv(int8 *in1, int8 *in2, int size){
+
+ int8 out[1] = { 0.0} ;
+ i8rdivma ( in1,1 ,size ,in2 , 1 , size , out );
+
+ return out[0] ;
+}
+
+
diff --git a/2.3-1/src/c/matrixOperations/division/u16ldivma.c b/2.3-1/src/c/matrixOperations/division/u16ldivma.c
new file mode 100644
index 00000000..fde268fe
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/u16ldivma.c
@@ -0,0 +1,111 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include "matrixDivision.h"
+#include "lapack.h"
+
+void u16ldivma (uint16* in1, int lines1, int columns1 ,
+ uint16* in2, int lines2, int columns2 ,
+ uint16* out ){
+
+
+ char cNorm = 0;
+ int iExit = 0;
+
+ /*temporary variables*/
+ int iWork = 0;
+ int iInfo = 0;
+ int iMax = 0;
+ uint16 dblRcond = 0;
+
+ uint16 dblEps = 0;
+ uint16 dblAnorm = 0;
+
+ uint16 *pAf = NULL;
+ uint16 *pXb = NULL;
+ uint16 *pDwork = NULL;
+
+ int *pRank = NULL;
+ int *pIpiv = NULL;
+ int *pJpvt = NULL;
+ int *pIwork = NULL;
+
+ iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2));
+
+
+ lines2 = 0 ;
+
+ /* Array allocations*/
+ pAf = (uint16*)malloc(sizeof(uint16) * (unsigned int) lines1 * (unsigned int) columns1);
+ pXb = (uint16*)malloc(sizeof(uint16) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2);
+
+ pRank = (int*)malloc(sizeof(int));
+ pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+ pJpvt = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+ pIwork = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+
+
+
+ cNorm = '1';
+ pDwork = (uint16*)malloc(sizeof(uint16) *(unsigned int)iWork);
+ dblEps = getRelativeMachinePrecision() ;
+
+ dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork);
+ if(lines1 == columns1)
+ {
+ cNorm = 'F';
+ dlacpy_(&cNorm, &columns1, &columns1, in1, &columns1, pAf, &columns1);
+ dgetrf_(&columns1, &columns1, pAf, &columns1, pIpiv, &iInfo);
+ if(iInfo == 0)
+ {
+ cNorm = '1';
+ C2F(dgecon)(&cNorm, &columns1, pAf, &columns1, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo);
+ if(dblRcond > sqrt(dblEps))
+ {
+ cNorm = 'N';
+ C2F(dgetrs)(&cNorm, &columns1, &columns2, pAf, &columns1, pIpiv, in2, &columns1, &iInfo);
+ cNorm = 'F';
+ C2F(dlacpy)(&cNorm, &columns1, &columns2, in2, &columns1, out, &columns1);
+ iExit = 1;
+ }
+ }
+
+ }
+
+ if(iExit == 0)
+ {
+ dblRcond = sqrt(dblEps);
+ cNorm = 'F';
+ iMax = max(lines1, columns1);
+ C2F(dlacpy)(&cNorm, &lines1, &columns2, in2, &lines1, pXb, &iMax);
+ memset(pJpvt, 0x00,(unsigned int) sizeof(int) * (unsigned int) columns1);
+ C2F(dgelsy)( &lines1, &columns1, &columns2, in1, &lines1, pXb, &iMax,
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+
+ if(iInfo == 0)
+ {
+
+ cNorm = 'F';
+ C2F(dlacpy)(&cNorm, &columns1, &columns2, pXb, &iMax, out, &columns1);
+ }
+ }
+
+ free(pAf);
+ free(pXb);
+ free(pRank);
+ free(pIpiv);
+ free(pJpvt);
+ free(pIwork);
+ free(pDwork);
+}
diff --git a/2.3-1/src/c/matrixOperations/division/u16rdivma.c b/2.3-1/src/c/matrixOperations/division/u16rdivma.c
new file mode 100644
index 00000000..a77db453
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/u16rdivma.c
@@ -0,0 +1,129 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include "matrixDivision.h"
+#include "lapack.h"
+
+void u16rdivma ( uint16 * in1, int lines1, int columns1,
+ uint16 * in2, int lines2, int columns2,
+ uint16 * out){
+
+ char cNorm = 0;
+ int iExit = 0;
+
+ /*temporary variables*/
+ int iWork = 0;
+ int iInfo = 0;
+ int iMax = 0;
+ uint16 dblRcond = 0;
+
+ uint16 dblEps = 0;
+ uint16 dblAnorm = 0;
+
+ uint16 *pAf = NULL;
+ uint16 *pAt = NULL;
+ uint16 *pBt = NULL;
+ uint16 *pDwork = NULL;
+
+ int *pRank = NULL;
+ int *pIpiv = NULL;
+ int *pJpvt = NULL;
+ int *pIwork = NULL;
+
+ iWork = max(4 * columns2, max(min(lines2, columns2) + 3 * lines2 + 1, 2 * min(lines2, columns2) + lines1));
+
+
+ /* Array allocations*/
+ pAf = (uint16*)malloc(sizeof(uint16) * (unsigned int)columns2 * (unsigned int)lines2);
+ pAt = (uint16*)malloc(sizeof(uint16) * (unsigned int)columns2 *(unsigned int) lines2);
+ pBt = (uint16*)malloc(sizeof(uint16) * (unsigned int)max(lines2,columns2) * (unsigned int)lines1);
+
+ pRank = (int*)malloc(sizeof(int));
+ pIpiv = (int*)malloc(sizeof(int) * (unsigned int)columns2);
+ pJpvt = (int*)malloc(sizeof(int) * (unsigned int)lines2);
+ pIwork = (int*)malloc(sizeof(int) * (unsigned int)columns2);
+
+
+ cNorm = '1';
+ pDwork = (uint16*)malloc(sizeof(uint16) * (unsigned int)iWork);
+ dblEps = getRelativeMachinePrecision() ;
+ dblAnorm = dlange_(&cNorm, &lines2, &columns1, in2, &lines2, pDwork);
+
+ /*tranpose A and B*/
+
+ dtransposea(in2, lines2, columns2, pAt);
+ dtransposea(in1, lines1, columns2, pBt);
+
+ if(lines2 == columns2)
+ {
+ cNorm = 'F';
+ dlacpy_(&cNorm, &columns2, &columns2, pAt, &columns2, pAf, &columns2);
+ dgetrf_(&columns2, &columns2, pAf, &columns2, pIpiv, &iInfo);
+ if(iInfo == 0)
+ {
+ cNorm = '1';
+ dgecon_(&cNorm, &columns2, pAf, &columns2, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo);
+ if(dblRcond > sqrt(dblEps))
+ {
+ cNorm = 'N';
+ dgetrs_(&cNorm, &columns2, &lines1, pAf, &columns2, pIpiv, pBt, &columns2, &iInfo);
+ dtransposea(pBt, columns2, lines1, out);
+ iExit = 1;
+ }
+ }
+
+ }
+
+ if(iExit == 0)
+ {
+ dblRcond = sqrt(dblEps);
+ cNorm = 'F';
+ iMax = max(lines2, columns2);
+ memset(pJpvt, 0x00, (unsigned int)sizeof(int) * (unsigned int)lines2);
+ dgelsy_(&columns2, &lines2, &lines1, pAt, &columns2, pBt, &iMax,
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+
+ if(iInfo == 0)
+ {
+
+
+ /* TransposeRealMatrix(pBt, lines1, lines2, out, Max(lines1,columns1), lines2);*/
+
+ /*Mega caca de la mort qui tue des ours a mains nues
+ mais je ne sais pas comment le rendre "beau" :(*/
+ {
+ int i,j,ij,ji;
+ for(j = 0 ; j < lines2 ; j++)
+ {
+ for(i = 0 ; i < lines1 ; i++)
+ {
+ ij = i + j * lines1;
+ ji = j + i * max(lines2, columns2);
+ out[ij] = pBt[ji];
+ }
+ }
+ }
+ }
+ }
+
+ free(pAf);
+ free(pAt);
+ free(pBt);
+ free(pRank);
+ free(pIpiv);
+ free(pJpvt);
+ free(pIwork);
+ free(pDwork);
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/division/u16rdivv.c b/2.3-1/src/c/matrixOperations/division/u16rdivv.c
new file mode 100644
index 00000000..9fc292c7
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/u16rdivv.c
@@ -0,0 +1,24 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - INRIA - Allan SIMON
+ *
+ * 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 "matrixDivision.h"
+
+uint16 u16rdivv(uint16 *in1, uint16 *in2, int size){
+
+ uint16 out[1] = { 0.0} ;
+ u16rdivma ( in1,1 ,size ,in2 , 1 , size , out );
+
+ return out[0] ;
+}
+
+
diff --git a/2.3-1/src/c/matrixOperations/division/u8ldivma.c b/2.3-1/src/c/matrixOperations/division/u8ldivma.c
new file mode 100644
index 00000000..a046fb41
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/u8ldivma.c
@@ -0,0 +1,111 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include "matrixDivision.h"
+#include "lapack.h"
+
+void u8ldivma (uint8* in1, int lines1, int columns1 ,
+ uint8* in2, int lines2, int columns2 ,
+ uint8* out ){
+
+
+ char cNorm = 0;
+ int iExit = 0;
+
+ /*temporary variables*/
+ int iWork = 0;
+ int iInfo = 0;
+ int iMax = 0;
+ uint8 dblRcond = 0;
+
+ uint8 dblEps = 0;
+ uint8 dblAnorm = 0;
+
+ uint8 *pAf = NULL;
+ uint8 *pXb = NULL;
+ uint8 *pDwork = NULL;
+
+ int *pRank = NULL;
+ int *pIpiv = NULL;
+ int *pJpvt = NULL;
+ int *pIwork = NULL;
+
+ iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2));
+
+
+ lines2 = 0 ;
+
+ /* Array allocations*/
+ pAf = (uint8*)malloc(sizeof(uint8) * (unsigned int) lines1 * (unsigned int) columns1);
+ pXb = (uint8*)malloc(sizeof(uint8) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2);
+
+ pRank = (int*)malloc(sizeof(int));
+ pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+ pJpvt = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+ pIwork = (int*)malloc(sizeof(int) *(unsigned int) columns1);
+
+
+
+ cNorm = '1';
+ pDwork = (uint8*)malloc(sizeof(uint8) *(unsigned int)iWork);
+ dblEps = getRelativeMachinePrecision() ;
+
+ dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork);
+ if(lines1 == columns1)
+ {
+ cNorm = 'F';
+ dlacpy_(&cNorm, &columns1, &columns1, in1, &columns1, pAf, &columns1);
+ dgetrf_(&columns1, &columns1, pAf, &columns1, pIpiv, &iInfo);
+ if(iInfo == 0)
+ {
+ cNorm = '1';
+ C2F(dgecon)(&cNorm, &columns1, pAf, &columns1, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo);
+ if(dblRcond > sqrt(dblEps))
+ {
+ cNorm = 'N';
+ C2F(dgetrs)(&cNorm, &columns1, &columns2, pAf, &columns1, pIpiv, in2, &columns1, &iInfo);
+ cNorm = 'F';
+ C2F(dlacpy)(&cNorm, &columns1, &columns2, in2, &columns1, out, &columns1);
+ iExit = 1;
+ }
+ }
+
+ }
+
+ if(iExit == 0)
+ {
+ dblRcond = sqrt(dblEps);
+ cNorm = 'F';
+ iMax = max(lines1, columns1);
+ C2F(dlacpy)(&cNorm, &lines1, &columns2, in2, &lines1, pXb, &iMax);
+ memset(pJpvt, 0x00,(unsigned int) sizeof(int) * (unsigned int) columns1);
+ C2F(dgelsy)( &lines1, &columns1, &columns2, in1, &lines1, pXb, &iMax,
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+
+ if(iInfo == 0)
+ {
+
+ cNorm = 'F';
+ C2F(dlacpy)(&cNorm, &columns1, &columns2, pXb, &iMax, out, &columns1);
+ }
+ }
+
+ free(pAf);
+ free(pXb);
+ free(pRank);
+ free(pIpiv);
+ free(pJpvt);
+ free(pIwork);
+ free(pDwork);
+}
diff --git a/2.3-1/src/c/matrixOperations/division/u8rdivma.c b/2.3-1/src/c/matrixOperations/division/u8rdivma.c
new file mode 100644
index 00000000..478f6ac9
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/u8rdivma.c
@@ -0,0 +1,129 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include "matrixDivision.h"
+#include "lapack.h"
+
+void u8rdivma ( uint8 * in1, int lines1, int columns1,
+ uint8 * in2, int lines2, int columns2,
+ uint8 * out){
+
+ char cNorm = 0;
+ int iExit = 0;
+
+ /*temporary variables*/
+ int iWork = 0;
+ int iInfo = 0;
+ int iMax = 0;
+ uint8 dblRcond = 0;
+
+ uint8 dblEps = 0;
+ uint8 dblAnorm = 0;
+
+ uint8 *pAf = NULL;
+ uint8 *pAt = NULL;
+ uint8 *pBt = NULL;
+ uint8 *pDwork = NULL;
+
+ int *pRank = NULL;
+ int *pIpiv = NULL;
+ int *pJpvt = NULL;
+ int *pIwork = NULL;
+
+ iWork = max(4 * columns2, max(min(lines2, columns2) + 3 * lines2 + 1, 2 * min(lines2, columns2) + lines1));
+
+
+ /* Array allocations*/
+ pAf = (uint8*)malloc(sizeof(uint8) * (unsigned int)columns2 * (unsigned int)lines2);
+ pAt = (uint8*)malloc(sizeof(uint8) * (unsigned int)columns2 *(unsigned int) lines2);
+ pBt = (uint8*)malloc(sizeof(uint8) * (unsigned int)max(lines2,columns2) * (unsigned int)lines1);
+
+ pRank = (int*)malloc(sizeof(int));
+ pIpiv = (int*)malloc(sizeof(int) * (unsigned int)columns2);
+ pJpvt = (int*)malloc(sizeof(int) * (unsigned int)lines2);
+ pIwork = (int*)malloc(sizeof(int) * (unsigned int)columns2);
+
+
+ cNorm = '1';
+ pDwork = (uint8*)malloc(sizeof(uint8) * (unsigned int)iWork);
+ dblEps = getRelativeMachinePrecision() ;
+ dblAnorm = dlange_(&cNorm, &lines2, &columns1, in2, &lines2, pDwork);
+
+ /*tranpose A and B*/
+
+ dtransposea(in2, lines2, columns2, pAt);
+ dtransposea(in1, lines1, columns2, pBt);
+
+ if(lines2 == columns2)
+ {
+ cNorm = 'F';
+ dlacpy_(&cNorm, &columns2, &columns2, pAt, &columns2, pAf, &columns2);
+ dgetrf_(&columns2, &columns2, pAf, &columns2, pIpiv, &iInfo);
+ if(iInfo == 0)
+ {
+ cNorm = '1';
+ dgecon_(&cNorm, &columns2, pAf, &columns2, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo);
+ if(dblRcond > sqrt(dblEps))
+ {
+ cNorm = 'N';
+ dgetrs_(&cNorm, &columns2, &lines1, pAf, &columns2, pIpiv, pBt, &columns2, &iInfo);
+ dtransposea(pBt, columns2, lines1, out);
+ iExit = 1;
+ }
+ }
+
+ }
+
+ if(iExit == 0)
+ {
+ dblRcond = sqrt(dblEps);
+ cNorm = 'F';
+ iMax = max(lines2, columns2);
+ memset(pJpvt, 0x00, (unsigned int)sizeof(int) * (unsigned int)lines2);
+ dgelsy_(&columns2, &lines2, &lines1, pAt, &columns2, pBt, &iMax,
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+
+ if(iInfo == 0)
+ {
+
+
+ /* TransposeRealMatrix(pBt, lines1, lines2, out, Max(lines1,columns1), lines2);*/
+
+ /*Mega caca de la mort qui tue des ours a mains nues
+ mais je ne sais pas comment le rendre "beau" :(*/
+ {
+ int i,j,ij,ji;
+ for(j = 0 ; j < lines2 ; j++)
+ {
+ for(i = 0 ; i < lines1 ; i++)
+ {
+ ij = i + j * lines1;
+ ji = j + i * max(lines2, columns2);
+ out[ij] = pBt[ji];
+ }
+ }
+ }
+ }
+ }
+
+ free(pAf);
+ free(pAt);
+ free(pBt);
+ free(pRank);
+ free(pIpiv);
+ free(pJpvt);
+ free(pIwork);
+ free(pDwork);
+
+}
+
diff --git a/2.3-1/src/c/matrixOperations/division/u8rdivv.c b/2.3-1/src/c/matrixOperations/division/u8rdivv.c
new file mode 100644
index 00000000..53ef809d
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/division/u8rdivv.c
@@ -0,0 +1,24 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - INRIA - Allan SIMON
+ *
+ * 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 "matrixDivision.h"
+
+uint8 u8rdivv(uint8 *in1, uint8 *in2, int size){
+
+ uint8 out[1] = { 0.0} ;
+ u8rdivma ( in1,1 ,size ,in2 , 1 , size , out );
+
+ return out[0] ;
+}
+
+
diff --git a/2.3-1/src/c/matrixOperations/includes/diag.h b/2.3-1/src/c/matrixOperations/includes/diag.h
new file mode 100644
index 00000000..b4ca929d
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/includes/diag.h
@@ -0,0 +1,96 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Allan SIMON
+ *
+ * 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
+ *
+ */
+
+#ifndef __DIAG_H__
+#define __DIAG_H__
+
+#include "dynlib_matrixoperations.h"
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EXTERN_MATOPS double ddiags(double in );
+
+EXTERN_MATOPS void ddiaga(double in, int size,int insert_post,double *out);
+
+EXTERN_MATOPS void ddiagina(double *in, int _row,int _column,int insert_post,double *out);
+
+EXTERN_MATOPS void ddiagins(double* in, int size, double* out );
+
+EXTERN_MATOPS void ddiagexa(double* in,int row,int column,int insert_pos,double* out);
+
+EXTERN_MATOPS double ddiagexs(double* in,int row,int column,int extract_pos);
+
+EXTERN_MATOPS uint8 u8diags(uint8 in );
+
+EXTERN_MATOPS void u8diaga(uint8 in, int size,int insert_post,uint8 *out);
+
+EXTERN_MATOPS void u8diagina(uint8 *in, int _row,int _column,int insert_post,uint8 *out);
+
+EXTERN_MATOPS void u8diagins(uint8* in, int size, uint8* out );
+
+EXTERN_MATOPS void u8diagexa(uint8* in,int row,int column,int insert_pos,uint8* out);
+
+EXTERN_MATOPS uint8 u8diagexs(uint8* in,int row,int column,int extract_pos);
+
+EXTERN_MATOPS uint16 u16diags(uint16 in );
+
+EXTERN_MATOPS void u16diaga(uint16 in, int size,int insert_post,uint16 *out);
+
+EXTERN_MATOPS void u16diagina(uint16 *in, int _row,int _column,int insert_post,uint16 *out);
+
+EXTERN_MATOPS void u16diagins(uint16* in, int size, uint16* out );
+
+EXTERN_MATOPS void u16diagexa(uint16* in,int row,int column,int insert_pos,uint16* out);
+
+EXTERN_MATOPS uint16 u16diagexs(uint16* in,int row,int column,int extract_pos);
+
+EXTERN_MATOPS int8 i8diags(int8 in );
+
+EXTERN_MATOPS void i8diaga(int8 in, int size,int insert_post,int8 *out);
+
+EXTERN_MATOPS void i8diagina(int8 *in, int _row,int _column,int insert_post,int8 *out);
+
+EXTERN_MATOPS void i8diagins(int8* in, int size, int8* out );
+
+EXTERN_MATOPS void i8diagexa(int8* in,int row,int column,int insert_pos,int8* out);
+
+EXTERN_MATOPS int8 i8diagexs(int8* in,int row,int column,int extract_pos);
+
+EXTERN_MATOPS int16 i16diags(int8 in );
+
+EXTERN_MATOPS void i16diaga(int16 in, int size,int insert_post,int16 *out);
+
+EXTERN_MATOPS void i16diagina(int16 *in, int _row,int _column,int insert_post,int16 *out);
+
+EXTERN_MATOPS void i16diagins(int16* in, int size, int16* out );
+
+EXTERN_MATOPS void i16diagexa(int16* in,int row,int column,int insert_pos,int16* out);
+
+EXTERN_MATOPS int16 i16diagexs(int16* in,int row,int column,int extract_pos);
+
+
+
+
+
+
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !__DIAG_H__ */
+
diff --git a/2.3-1/src/c/matrixOperations/interfaces/int_diag.h b/2.3-1/src/c/matrixOperations/interfaces/int_diag.h
new file mode 100644
index 00000000..4d6553c5
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/interfaces/int_diag.h
@@ -0,0 +1,87 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
+ *
+ * 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
+ *
+ */
+
+/* THIS IS AN AUTOMATICALLY GENERATED FILE : DO NOT EDIT BY HAND. */
+
+#ifndef __INT_DIAG_H__
+#define __INT_DIAG_H__
+
+
+
+#define d0diagd0(in1) ddiags(in1)
+
+#define d0d0diagd0(in1,in2) ddiags(in1)
+
+#define d0d0diagd2(in1,in2,out) ddiaga(in1,1,in2,out)
+
+#define d2diagd2(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? ddiagins(in1,size[1],out) : ddiagins(in1,size[0],out); } else {ddiagexa(in1,size[0],size[1],0,out) ;}
+
+#define d2d0diagd2(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { ddiagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {ddiagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? ddiagins(in1,size[1],out) : ddiagins(in1,size[0],out); };}
+
+#define d2d0diagd0(in1,size,in2) ddiagexs(in1,size[0],size[1],in2)
+
+
+
+#define u80diagu80(in1) u8diags(in1)
+
+#define u80d0diagu80(in1,in2) u8diags(in1)
+
+#define u80d0diagu82(in1,in2,out) u8diaga(in1,1,in2,out)
+
+#define u82diagu82(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? u8diagins(in1,size[1],out) : u8diagins(in1,size[0],out); } else {u8diagexa(in1,size[0],size[1],0,out) ;}
+
+#define u82d0diagu82(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { u8diagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {u8diagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? u8diagins(in1,size[1],out) : u8diagins(in1,size[0],out); };}
+
+#define u82d0diagu80(in1,size,in2) u8diagexs(in1,size[0],size[1],in2)
+
+#define u160diagu160(in1) u16diags(in1)
+
+#define u160d0diagu160(in1,in2) u16diags(in1)
+
+#define u160d0diagu162(in1,in2,out) u16diaga(in1,1,in2,out)
+
+#define u162diagu162(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? u16diagins(in1,size[1],out) : u16diagins(in1,size[0],out); } else {u16diagexa(in1,size[0],size[1],0,out) ;}
+
+#define u162d0diagu162(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { u16diagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {u16diagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? u16diagins(in1,size[1],out) : u16diagins(in1,size[0],out); };}
+
+#define u162d0diagu160(in1,size,in2) u16diagexs(in1,size[0],size[1],in2)
+
+
+
+#define i80diagi80(in1) i8diags(in1)
+
+#define i80d0diagi80(in1,in2) i8diags(in1)
+
+#define i80d0diagi82(in1,in2,out) i8diaga(in1,1,in2,out)
+
+#define i82diagi82(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? i8diagins(in1,size[1],out) : i8diagins(in1,size[0],out); } else {i8diagexa(in1,size[0],size[1],0,out) ;}
+
+#define i82d0diagi82(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { i8diagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {i8diagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? i8diagins(in1,size[1],out) : i8diagins(in1,size[0],out); };}
+
+#define i82d0diagi80(in1,size,in2) i8diagexs(in1,size[0],size[1],in2)
+
+#define i160diagi160(in1) i16diags(in1)
+
+#define i160d0diagi160(in1,in2) i16diags(in1)
+
+#define i160d0diagi162(in1,in2,out) i16diaga(in1,1,in2,out)
+
+
+#define i162diagi162(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? i16diagins(in1,size[1],out) : i16diagins(in1,size[0],out); } else {i16diagexa(in1,size[0],size[1],0,out) ;}
+
+#define i162d0diagi162(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { i16diagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {i16diagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? i16diagins(in1,size[1],out) : i16diagins(in1,size[0],out); };}
+
+#define i162d0diagi160(in1,size,in2) i16diagexs(in1,size[0],size[1],in2)
+
+
+
+#endif /* !__INT_DIAG_H__ */