diff options
Diffstat (limited to 'src/c/CACSD')
-rw-r--r-- | src/c/CACSD/includes/syslin.h | 31 | ||||
-rw-r--r-- | src/c/CACSD/interfaces/int_syslin.h | 78 | ||||
-rw-r--r-- | src/c/CACSD/syslin/dsyslina.c | 94 |
3 files changed, 203 insertions, 0 deletions
diff --git a/src/c/CACSD/includes/syslin.h b/src/c/CACSD/includes/syslin.h new file mode 100644 index 0000000..7d361c9 --- /dev/null +++ b/src/c/CACSD/includes/syslin.h @@ -0,0 +1,31 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#ifndef __SYSLIN_H__ +#define __SYSLIN_H__ + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +void dsyslina(double* A, int no_of_states, double* B, int no_of_inputs, \ + double* C, int no_of_outputs, double* D, double* X0, double* out); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__SYSLIN_H__*/
\ No newline at end of file diff --git a/src/c/CACSD/interfaces/int_syslin.h b/src/c/CACSD/interfaces/int_syslin.h new file mode 100644 index 0000000..2327c38 --- /dev/null +++ b/src/c/CACSD/interfaces/int_syslin.h @@ -0,0 +1,78 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#ifndef __INT_SYSLIN_H__ +#define __INT_SYSLIN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define g2d2d2d2syslinss2(in1,size1,in2,size2,in3,size3,in4,size4,out) \ + dsyslina(in2,size2[0],in3,size3[1],in4,size4[0],NULL,NULL,out) + +#define g2d2d2d2d2syslinss2(in1,size1,in2,size2,in3,size3,in4,size4,in5, \ + size5,out) dsyslina(in2,size2[0],in3,size3[1],in4,size4[0],in5,NULL,out) + +#define g2d2d2d2d2d2syslinss2(in1,size1,in2,size2,in3,size3,in4,size4, \ + in5,size5,in6,size6,out) dsyslina(in2,size2[0],in3,size3[1],in4, \ + size4[0],in5,in6,out) +// +#define g2d0d0d0syslinss2(in1,size1,in2,in3,in4,out) \ + dsyslina(in2,1,in3,1,in4,1,NULL,NULL,out) + +#define g2d0d2d0syslinss2(in1,size1,in2,in3,size3,in4,out) \ + dsyslina(in2,1,in3,size3[1],in4,1,NULL,NULL,out) + +#define g2d0d0d2syslinss2(in1,size1,in2,in3,in4,size4,out) \ + dsyslina(in2,1,in3,1,in4,size4[0],NULL,NULL,out) + +#define g2d0d2d2syslinss2(in1,size1,in2,in3,size3,in4,size4,out) \ + dsyslina(in2,1,in3,size3[1],in4,size4[0],NULL,NULL,out) +// +#define g2d0d0d0d0syslinss2(in1,size1,in2,in3,in4,in5,out) \ + dsyslina(in2,1,in3,1,in4,1,in5,NULL,out) + +#define g2d0d2d0d2syslinss2(in1,size1,in2,in3,size3,in4,in5,size5, \ + out) dsyslina(in2,1,in3,size3[1],in4,1,in5,NULL,out) + +#define g2d0d0d2d2syslinss2(in1,size1,in2,in3,in4,size4,in5,size5, \ + out) dsyslina(in2,1,in3,1,in4,size4[0],in5,NULL,out) + +#define g2d0d2d2d2syslinss2(in1,size1,in2,in3,size3,in4,size4,in5, \ + size5, out) dsyslina(in2,1,in3,size3[1],in4,size4[0],in5,NULL,out) + +#define g2d2d2d2d0syslinss2(in1,size1,in2,size2,in3,size3,in4,size4, \ + in5,out) dsyslina(in2,size2[0],in3,size3[1],in4,size4[0],in5,NULL,out) +// +#define g2d0d0d0d0d0syslinss2(in1,size1,in2,in3,in4,in5,in6,out) \ + dsyslina(in2,1,in3,1,in4,1,in5,in6,out) + +#define g2d0d2d0d2d0syslinss2(in1,size1,in2,in3,size3,in4,in5,size5, \ + in6,out) dsyslina(in2,1,in3,size3[1],in4,1,in5,in6,out) + +#define g2d0d0d2d2d0syslinss2(in1,size1,in2,in3,in4,size4,in5,size5, \ + in6,out) dsyslina(in2,1,in3,1,in4,size4[0],in5,in6,out) + +#define g2d0d2d2d2d0syslinss2(in1,size1,in2,in3,size3,in4,size4,in5, \ + size5,in6,out) dsyslina(in2,1,in3,size3[1],in4,size4[0],in5,in6,out) + +#define g2d2d2d2d0d2syslinss2(in1,size1,in2,size2,in3,size3,in4,size4, \ + in5,in6,size6,out) dsyslina(in2,size2[0],in3,size3[1],in4,size4[0], \ + in5,in6,out) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /*__INT_SYSLIN_H__*/
\ No newline at end of file diff --git a/src/c/CACSD/syslin/dsyslina.c b/src/c/CACSD/syslin/dsyslina.c new file mode 100644 index 0000000..cd7fa6b --- /dev/null +++ b/src/c/CACSD/syslin/dsyslina.c @@ -0,0 +1,94 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function for declaring state space system*/ + +#include <stdlib.h> + +void dsyslina(double* A, int no_of_states, double* B, int no_of_inputs, \ + double* C, int no_of_outputs, double* D, double* X0, double* out) +{ + int row = 0,col = 0; + int no_of_cols = no_of_states + no_of_inputs + 1; + + /*Copy matrix A into out matrix*/ + for(row = 0; row < no_of_states; row++) + { + for(col = 0; col < no_of_states; col++) + { + out[row*no_of_cols + col] = A[row*no_of_states + col]; + } + + } + + /*Copy matrix B in out matrix*/ + for(row = 0; row < no_of_states; row++) + { + for(col=0; col < no_of_inputs; col++) + { + out[row * no_of_cols + no_of_states + col] = B[row * no_of_inputs + col]; + } + } + + /*Copy matrix C in out matrix*/ + for(row = 0; row < no_of_outputs; row++) + { + for(col=0; col < no_of_states; col++) + { + out[(no_of_states + row)*no_of_cols + col] = C[row * no_of_states + col]; + } + } + + /*Copy matrix D in out matrix*/ + if( D != NULL) + { + for(row = 0; row < no_of_outputs; row++) + { + for(col=0; col < no_of_inputs; col++) + { + out[(no_of_states+row)*no_of_cols + no_of_states+col] = \ + D[row * no_of_inputs + col]; + } + } + } + else + { + for(row = 0; row < no_of_outputs; row++) + { + for(col=0; col < no_of_inputs; col++) + { + out[(no_of_states+row)*no_of_cols + no_of_states+col] = 0; + } + } + } + + /*Copy matrix X0 in out matrix*/ + if( X0 != NULL) + { + for(row = 0; row < no_of_states; row++) + { + out[(row+1)*(no_of_cols) - 1] = X0[row]; + + } + } + else + { + for(row = 0; row < no_of_states; row++) + { + out[(row+1)*(no_of_cols) - 1] = 0; + + } + } + + + +}
\ No newline at end of file |