From e6ba6e9161124c6ae041b26d369c961a97cf080a Mon Sep 17 00:00:00 2001 From: torset Date: Thu, 11 Dec 2008 15:12:01 +0000 Subject: Add determ --- src/matrixOperations/determ/sdeterma.c | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/matrixOperations/determ/sdeterma.c (limited to 'src/matrixOperations/determ/sdeterma.c') diff --git a/src/matrixOperations/determ/sdeterma.c b/src/matrixOperations/determ/sdeterma.c new file mode 100644 index 00000000..bef0d728 --- /dev/null +++ b/src/matrixOperations/determ/sdeterma.c @@ -0,0 +1,97 @@ +/* + * 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 + * + */ + + +#ifndef WITHOUT_LAPACK +#include "lapack.h" +#endif +#include "determ.h" +#include +#include + +float sdeterma(float * in, int size){ +#ifndef WITHOUT_LAPACK + float out; + double *inCopy; + int* tmp; + int info=0,i=0; + + + + /*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((uint)(size*size)*sizeof(double)); + tmp=malloc((uint)size*sizeof(int)); + for (i=0;i