summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/CACSD/syslin/dsyslina.c
diff options
context:
space:
mode:
authorsiddhu89902017-02-02 16:02:41 +0530
committersiddhu89902017-02-02 16:02:41 +0530
commit1fef9b1edc2d4400e8ba6bb6fafb648963d6817d (patch)
treee1f37ced7b25b855d327895c3932e051232606a1 /2.3-1/src/c/CACSD/syslin/dsyslina.c
parent28d16508c39756d1f143b44c33115530fd4a7653 (diff)
downloadScilab2C-1fef9b1edc2d4400e8ba6bb6fafb648963d6817d.tar.gz
Scilab2C-1fef9b1edc2d4400e8ba6bb6fafb648963d6817d.tar.bz2
Scilab2C-1fef9b1edc2d4400e8ba6bb6fafb648963d6817d.zip
Support for function 'schur' added
q
Diffstat (limited to '2.3-1/src/c/CACSD/syslin/dsyslina.c')
-rw-r--r--2.3-1/src/c/CACSD/syslin/dsyslina.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/2.3-1/src/c/CACSD/syslin/dsyslina.c b/2.3-1/src/c/CACSD/syslin/dsyslina.c
new file mode 100644
index 00000000..cd7fa6bc
--- /dev/null
+++ b/2.3-1/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