summaryrefslogtreecommitdiffstats
path: root/scilab/modules/call_scilab
diff options
context:
space:
mode:
authorAllan CORNET <allan.cornet@scilab.org>2010-01-26 11:41:01 +0100
committerAllan CORNET <allan.cornet@scilab.org>2010-01-26 11:41:01 +0100
commitb647c4f12fc297552aad087b7b3caa585382248b (patch)
tree0845f041feeb704a09803a1346a06382a9cee860 /scilab/modules/call_scilab
parentff3fb6e4b17709fc36db10fa4c41f2ed64165746 (diff)
parenta886d411e2b4b19da5b84d1645033d4c140857c4 (diff)
downloadscilab-b647c4f12fc297552aad087b7b3caa585382248b.zip
scilab-b647c4f12fc297552aad087b7b3caa585382248b.tar.gz
Merge branch 'master' of git.scilab.org:scilab
Diffstat (limited to 'scilab/modules/call_scilab')
-rw-r--r--scilab/modules/call_scilab/examples/basicExamples/DisableInteractiveMode.c2
-rw-r--r--scilab/modules/call_scilab/examples/basicExamples/GetLastJob.c2
-rw-r--r--scilab/modules/call_scilab/examples/basicExamples/readwriteboolean.c2
-rw-r--r--scilab/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c89
-rw-r--r--scilab/modules/call_scilab/examples/basicExamples/readwritematrix.c2
-rw-r--r--scilab/modules/call_scilab/examples/basicExamples/readwritestring.c2
-rw-r--r--scilab/modules/call_scilab/examples/call_scilab/c/LabWindow/CallsciC.c4
-rw-r--r--scilab/modules/call_scilab/examples/call_scilab/c/common/myprog.c4
-rw-r--r--scilab/modules/call_scilab/examples/call_scilab/c/common/simple_call_scilab.c2
-rw-r--r--scilab/modules/call_scilab/examples/call_scilab/c/visual_studio/CallsciC.c4
-rw-r--r--scilab/modules/call_scilab/examples/call_scilab/cpp/common/myprog.c2
-rw-r--r--scilab/modules/call_scilab/help/en_US/ComplexManagement.xml38
-rw-r--r--scilab/modules/call_scilab/help/en_US/cwritecmat.xml2
13 files changed, 121 insertions, 34 deletions
diff --git a/scilab/modules/call_scilab/examples/basicExamples/DisableInteractiveMode.c b/scilab/modules/call_scilab/examples/basicExamples/DisableInteractiveMode.c
index 031c745..0715f4a 100644
--- a/scilab/modules/call_scilab/examples/basicExamples/DisableInteractiveMode.c
+++ b/scilab/modules/call_scilab/examples/basicExamples/DisableInteractiveMode.c
@@ -9,7 +9,7 @@
9#include <string.h> 9#include <string.h>
10 10
11#include "stack-c.h" /* Provide functions to access to the memory of Scilab */ 11#include "stack-c.h" /* Provide functions to access to the memory of Scilab */
12#include "CallScilab.h" /* Provide functions to call Scilab engine */ 12#include "call_scilab.h" /* Provide functions to call Scilab engine */
13 13
14/*------------------------------------------------------------*/ 14/*------------------------------------------------------------*/
15int main(void) 15int main(void)
diff --git a/scilab/modules/call_scilab/examples/basicExamples/GetLastJob.c b/scilab/modules/call_scilab/examples/basicExamples/GetLastJob.c
index 77267c3..5d0bc39 100644
--- a/scilab/modules/call_scilab/examples/basicExamples/GetLastJob.c
+++ b/scilab/modules/call_scilab/examples/basicExamples/GetLastJob.c
@@ -9,7 +9,7 @@
9#include <string.h> 9#include <string.h>
10 10
11#include "stack-c.h" /* Provide functions to access to the memory of Scilab */ 11#include "stack-c.h" /* Provide functions to access to the memory of Scilab */
12#include "CallScilab.h" /* Provide functions to call Scilab engine */ 12#include "call_scilab.h" /* Provide functions to call Scilab engine */
13 13
14/*------------------------------------------------------------*/ 14/*------------------------------------------------------------*/
15int main(void) 15int main(void)
diff --git a/scilab/modules/call_scilab/examples/basicExamples/readwriteboolean.c b/scilab/modules/call_scilab/examples/basicExamples/readwriteboolean.c
index a464cf6..186bba3 100644
--- a/scilab/modules/call_scilab/examples/basicExamples/readwriteboolean.c
+++ b/scilab/modules/call_scilab/examples/basicExamples/readwriteboolean.c
@@ -15,7 +15,7 @@
15#include <stdlib.h> /* malloc */ 15#include <stdlib.h> /* malloc */
16#include "api_scilab.h" 16#include "api_scilab.h"
17#include "stack-c.h" /* Provide functions to access to the memory of Scilab */ 17#include "stack-c.h" /* Provide functions to access to the memory of Scilab */
18#include "CallScilab.h" /* Provide functions to call Scilab engine */ 18#include "call_scilab.h" /* Provide functions to call Scilab engine */
19 19
20/*------------------------------------------------------------*/ 20/*------------------------------------------------------------*/
21int main(void) 21int main(void)
diff --git a/scilab/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c b/scilab/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c
index 5c2ef00..e4bd045 100644
--- a/scilab/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c
+++ b/scilab/modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c
@@ -10,9 +10,10 @@
10#include <math.h> 10#include <math.h>
11#include <stdio.h> 11#include <stdio.h>
12#include <stdlib.h> 12#include <stdlib.h>
13#include <string.h> 13#include <string.h>
14#include "api_scilab.h"
14#include "stack-c.h" /* Provide functions to access to the memory of Scilab */ 15#include "stack-c.h" /* Provide functions to access to the memory of Scilab */
15#include "CallScilab.h" /* Provide functions to call Scilab engine */ 16#include "call_scilab.h" /* Provide functions to call Scilab engine */
16/*------------------------------------------------------------*/ 17/*------------------------------------------------------------*/
17int main(void) 18int main(void)
18{ 19{
@@ -32,14 +33,25 @@ int main(void)
32 * A=[ 1+%i 3 3+7*%i 2-2*%i ]; 33 * A=[ 1+%i 3 3+7*%i 2-2*%i ];
33 */ 34 */
34 { 35 {
35 double A[]={1,3,3,2,1,0,7,-2}; /* Declare the complex matrix */ 36/* Declare the complex matrix */
37 double A[]={1,3,3,2};
38 double A_img[]={1,0,7,-2};
39/*
40 * Prior to Scilab 5.2:
41 * double A[]={1,3,3,2,1,0,7,-2};
42 */
36 int rowA=1, colA=4; /* Size of the complex matrix 43 int rowA=1, colA=4; /* Size of the complex matrix
37 * (note that colA = sizeof(A)/2 44 * (note that colA = sizeof(A)/2
38 */ 45 */
39 char variableName[]="A"; 46 char variableName[]="A";
40 47
41 C2F(cwritecmat)(variableName, &rowA, &colA, A,strlen(variableName)); /* Write it into Scilab's memory */ 48/* Write it into Scilab's memory */
49 createNamedComplexMatrixOfDouble(pvApiCtx,variableName,rowA,colA, A, A_img);
42 50
51/*
52 * Prior to Scilab 5.2:
53 * C2F(cwritecmat)(variableName, &rowA, &colA, A,strlen(variableName));
54 */
43 printf("Display from Scilab of A:\n"); 55 printf("Display from Scilab of A:\n");
44 SendScilabJob("disp(A);"); /* Display A */ 56 SendScilabJob("disp(A);"); /* Display A */
45 } 57 }
@@ -51,10 +63,23 @@ int main(void)
51 * Note that it is done column by column 63 * Note that it is done column by column
52 */ 64 */
53 { 65 {
54 double B[]={1,3,4,9,2,8,3,2,1,0,-1,0,1/2,42,0,0}; /* Declare the matrix */ 66
67 double B[]={1,3,4,9,2,8,3,2};
68 double B_img[]={1,0.233,-1,-0.2,0.5,42,-23,123}; /* Declare the matrix */
69/*
70 * Prior to Scilab 5.2:
71 * double B[]={1,3,4,9,2,8,3,2,1,0.233,-1,-0.2,0.5,42,-23,123};
72 */
73
55 int rowB=2, colB=4; /* Size of the matrix */ 74 int rowB=2, colB=4; /* Size of the matrix */
56 char variableNameB[] = "B"; 75 char variableNameB[] = "B";
57 C2F(cwritecmat)(variableNameB, &rowB, &colB, B, strlen(variableNameB)); /* Write it into Scilab's memory */ 76/* Write it into Scilab's memory */
77 createNamedComplexMatrixOfDouble(pvApiCtx,variableNameB, rowB, colB, B, B_img);
78
79/*
80 * Prior to Scilab 5.2:
81 * C2F(cwritecmat)(variableNameB, &rowB, &colB, B, strlen(variableNameB));
82 */
58 printf("\n"); 83 printf("\n");
59 printf("Display from Scilab of B:\n"); 84 printf("Display from Scilab of B:\n");
60 SendScilabJob("disp(B);"); /* Display B */ 85 SendScilabJob("disp(B);"); /* Display B */
@@ -68,18 +93,29 @@ int main(void)
68 int rowA_ = 0, colA_ = 0,lp = 0; 93 int rowA_ = 0, colA_ = 0,lp = 0;
69 int i = 0,j = 0; 94 int i = 0,j = 0;
70 double *matrixOfComplex = NULL; 95 double *matrixOfComplex = NULL;
96 double *matrixOfComplex_img = NULL;
71 97
72 char variableToBeRetrieved[] = "A"; 98 char variableToBeRetrieved[] = "A";
73 99
74 /* First, retrieve the size of the matrix */ 100 /* First, retrieve the size of the matrix */
75 C2F(cmatcptr)(variableToBeRetrieved, &rowA_, &colA_, &lp, strlen(variableToBeRetrieved)); 101 readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrieved, &rowA_, &colA_, NULL, NULL);
102
103/*
104 * Prior to Scilab 5.2:
105 * C2F(cmatcptr)(variableToBeRetrieved, &rowA_, &colA_, &lp, strlen(variableToBeRetrieved));
106 */
76 107
77 /* Alloc the memory */ 108 /* Alloc the memory */
78 matrixOfComplex = (double*)malloc((rowA_*colA_*2)*sizeof(double)); 109 matrixOfComplex = (double*)malloc((rowA_*colA_*2)*sizeof(double));
110 matrixOfComplex_img = (double*)malloc((rowA_*colA_*2)*sizeof(double));
79 111
80 /* Load the matrix */ 112 /* Load the matrix */
81 C2F(creadcmat)(variableToBeRetrieved,&rowA_,&colA_,matrixOfComplex,strlen(variableToBeRetrieved) ); 113 readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrieved, &rowA_, &colA_, matrixOfComplex, matrixOfComplex_img);
82 114
115/*
116 * Prior to Scilab 5.2:
117 * C2F(creadcmat)(variableToBeRetrieved,&rowA_,&colA_,matrixOfComplex,strlen(variableToBeRetrieved) );
118 */
83 printf("\n"); 119 printf("\n");
84 printf("Display raw A (size: %d, %d):\n", rowA_, colA_); 120 printf("Display raw A (size: %d, %d):\n", rowA_, colA_);
85 for(i=0; i < rowA_*colA_*2; i++) /* *2 is because complex part is store 121 for(i=0; i < rowA_*colA_*2; i++) /* *2 is because complex part is store
@@ -110,26 +146,46 @@ int main(void)
110 int i = 0,j = 0; 146 int i = 0,j = 0;
111 147
112 double *matrixOfComplexB = NULL; 148 double *matrixOfComplexB = NULL;
149 double *matrixOfComplexB_img = NULL;
113 char variableToBeRetrievedB[] = "B"; 150 char variableToBeRetrievedB[] = "B";
114 151
115 /* First, retrieve the size of the matrix */ 152 /* First, retrieve the size of the matrix */
116 C2F(cmatcptr)(variableToBeRetrievedB, &rowB_, &colB_, &lp_, strlen(variableToBeRetrievedB)); 153
154 readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, NULL, NULL);
155/*
156 * Prior to Scilab 5.2:
157 * C2F(cmatcptr)(variableToBeRetrievedB, &rowB_, &colB_, &lp_, strlen(variableToBeRetrievedB));
158 */
117 159
118 /* Alloc the memory */ 160 /* Alloc the memory */
119 matrixOfComplexB = (double*)malloc((rowB_*colB_*2)*sizeof(double)); 161 matrixOfComplexB = (double*)malloc((rowB_*colB_)*sizeof(double));
162 matrixOfComplexB_img = (double*)malloc((rowB_*colB_)*sizeof(double));
120 163
121 /* Load the matrix */ 164 /* Load the matrix */
122 C2F(creadcmat)(variableToBeRetrievedB,&rowB_,&colB_,matrixOfComplexB,strlen(variableToBeRetrievedB) ); 165 readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, matrixOfComplexB, matrixOfComplexB_img);
166
167/*
168 * Prior to Scilab 5.2:
169 * C2F(creadcmat)(variableToBeRetrievedB,&rowB_,&colB_,matrixOfComplexB,strlen(variableToBeRetrievedB) );
170 */
123 171
124 printf("\n"); 172 printf("\n");
125 printf("Display from B raw (size: %d, %d):\n",rowB_, colB_); 173 printf("Display from B raw - real part (size: %d, %d):\n",rowB_, colB_);
126 for(i=0; i < rowB_*colB_*2; i++) /* *2 is because complex part is store 174 for(i=0; i < rowB_*colB_; i++) /* *2 is because complex part is store
127 * at the end 175 * at the end
128 */ 176 */
129 { 177 {
130 /* Display the raw matrix */ 178 /* Display the raw matrix */
131 fprintf(stdout,"B[%d] = %5.2f\n",i,matrixOfComplexB[i]); 179 fprintf(stdout,"B[%d] = %5.2f\n",i,matrixOfComplexB[i]);
132 } 180 }
181 printf("Display from B raw - imaginary part (size: %d, %d):\n",rowB_, colB_);
182 for(i=0; i < rowB_*colB_; i++) /* *2 is because complex part is store
183 * at the end
184 */
185 {
186 /* Display the raw matrix */
187 fprintf(stdout,"B[%d] = %5.2f\n",i,matrixOfComplexB_img[i]);
188 }
133 189
134 printf("\n"); 190 printf("\n");
135 printf("Display from B formated (size: %d, %d):\n",rowB_, colB_); 191 printf("Display from B formated (size: %d, %d):\n",rowB_, colB_);
@@ -139,7 +195,7 @@ int main(void)
139 { 195 {
140 /* Display the formated matrix ... the way the user 196 /* Display the formated matrix ... the way the user
141 * expect */ 197 * expect */
142 printf("%5.2f + %5.2f.i ",matrixOfComplexB[i * rowB_ + j],matrixOfComplexB[(rowB_*colB_)+(i * rowB_ + j)]); 198 printf("%5.2f + %5.2f.i ",matrixOfComplexB[i * rowB_ + j],matrixOfComplexB_img[i * rowB_ + j]);
143 } 199 }
144 printf("\n"); /* New row of the matrix */ 200 printf("\n"); /* New row of the matrix */
145 } 201 }
@@ -149,6 +205,11 @@ int main(void)
149 free(matrixOfComplexB); 205 free(matrixOfComplexB);
150 matrixOfComplexB=NULL; 206 matrixOfComplexB=NULL;
151 } 207 }
208 if (matrixOfComplexB_img)
209 {
210 free(matrixOfComplexB_img);
211 matrixOfComplexB_img=NULL;
212 }
152 } 213 }
153 214
154 if ( TerminateScilab(NULL) == FALSE ) { 215 if ( TerminateScilab(NULL) == FALSE ) {
diff --git a/scilab/modules/call_scilab/examples/basicExamples/readwritematrix.c b/scilab/modules/call_scilab/examples/basicExamples/readwritematrix.c
index 0426c03..48e550e 100644
--- a/scilab/modules/call_scilab/examples/basicExamples/readwritematrix.c
+++ b/scilab/modules/call_scilab/examples/basicExamples/readwritematrix.c
@@ -14,7 +14,7 @@
14#include <stdlib.h> 14#include <stdlib.h>
15#include "api_scilab.h" 15#include "api_scilab.h"
16#include "stack-c.h" /* Provide functions to access to the memory of Scilab */ 16#include "stack-c.h" /* Provide functions to access to the memory of Scilab */
17#include "CallScilab.h" /* Provide functions to call Scilab engine */ 17#include "call_scilab.h" /* Provide functions to call Scilab engine */
18 18
19/*------------------------------------------------------------*/ 19/*------------------------------------------------------------*/
20int main(void) 20int main(void)
diff --git a/scilab/modules/call_scilab/examples/basicExamples/readwritestring.c b/scilab/modules/call_scilab/examples/basicExamples/readwritestring.c
index 737d245..929bae9 100644
--- a/scilab/modules/call_scilab/examples/basicExamples/readwritestring.c
+++ b/scilab/modules/call_scilab/examples/basicExamples/readwritestring.c
@@ -12,7 +12,7 @@
12#include <string.h> 12#include <string.h>
13#include "api_scilab.h" 13#include "api_scilab.h"
14#include "stack-c.h" /* Provide functions to access to the memory of Scilab */ 14#include "stack-c.h" /* Provide functions to access to the memory of Scilab */
15#include "CallScilab.h" /* Provide functions to call Scilab engine */ 15#include "call_scilab.h" /* Provide functions to call Scilab engine */
16 16
17/*------------------------------------------------------------*/ 17/*------------------------------------------------------------*/
18int main(void) 18int main(void)
diff --git a/scilab/modules/call_scilab/examples/call_scilab/c/LabWindow/CallsciC.c b/scilab/modules/call_scilab/examples/call_scilab/c/LabWindow/CallsciC.c
index d810872..d067eb4 100644
--- a/scilab/modules/call_scilab/examples/call_scilab/c/LabWindow/CallsciC.c
+++ b/scilab/modules/call_scilab/examples/call_scilab/c/LabWindow/CallsciC.c
@@ -8,10 +8,10 @@
8#include <stdlib.h> 8#include <stdlib.h>
9#include <stdio.h> 9#include <stdio.h>
10#include <string.h> 10#include <string.h>
11#include "CallScilab.h" 11#include "call_scilab.h"
12#include "stack-c.h" 12#include "stack-c.h"
13/*--------------------------------------------------------------------------*/ 13/*--------------------------------------------------------------------------*/
14/* See SCI/modules/core/includes/CallScilab.h */ 14/* See SCI/modules/core/includes/call_scilab.h */
15/*--------------------------------------------------------------------------*/ 15/*--------------------------------------------------------------------------*/
16static int example1(void) 16static int example1(void)
17{ 17{
diff --git a/scilab/modules/call_scilab/examples/call_scilab/c/common/myprog.c b/scilab/modules/call_scilab/examples/call_scilab/c/common/myprog.c
index d287d35..4b34d73 100644
--- a/scilab/modules/call_scilab/examples/call_scilab/c/common/myprog.c
+++ b/scilab/modules/call_scilab/examples/call_scilab/c/common/myprog.c
@@ -15,7 +15,7 @@
15#include <string.h> 15#include <string.h>
16 16
17#include "stack-c.h" /* Provide functions to access to the memory of Scilab */ 17#include "stack-c.h" /* Provide functions to access to the memory of Scilab */
18#include "CallScilab.h" /* Provide functions to call Scilab engine */ 18#include "call_scilab.h" /* Provide functions to call Scilab engine */
19 19
20/** 20/**
21 * 21 *
@@ -28,7 +28,7 @@
28#define TRUE 1 28#define TRUE 1
29#define FALSE 0 29#define FALSE 0
30/*------------------------------------------------------------*/ 30/*------------------------------------------------------------*/
31/* See SCI/modules/core/includes/CallScilab.h */ 31/* See SCI/modules/core/includes/call_scilab.h */
32/*------------------------------------------------------------*/ 32/*------------------------------------------------------------*/
33static int first_example(void) 33static int first_example(void)
34{ 34{
diff --git a/scilab/modules/call_scilab/examples/call_scilab/c/common/simple_call_scilab.c b/scilab/modules/call_scilab/examples/call_scilab/c/common/simple_call_scilab.c
index 7c4688b..cc5e15f 100644
--- a/scilab/modules/call_scilab/examples/call_scilab/c/common/simple_call_scilab.c
+++ b/scilab/modules/call_scilab/examples/call_scilab/c/common/simple_call_scilab.c
@@ -9,7 +9,7 @@
9#include <stdio.h> /* stderr */ 9#include <stdio.h> /* stderr */
10 10
11#include "stack-c.h" /* Provide functions to access to the memory of Scilab */ 11#include "stack-c.h" /* Provide functions to access to the memory of Scilab */
12#include "CallScilab.h" /* Provide functions to call Scilab engine */ 12#include "call_scilab.h" /* Provide functions to call Scilab engine */
13 13
14 14
15// Filename: simple_call_scilab.c 15// Filename: simple_call_scilab.c
diff --git a/scilab/modules/call_scilab/examples/call_scilab/c/visual_studio/CallsciC.c b/scilab/modules/call_scilab/examples/call_scilab/c/visual_studio/CallsciC.c
index be5d762..a372c5f 100644
--- a/scilab/modules/call_scilab/examples/call_scilab/c/visual_studio/CallsciC.c
+++ b/scilab/modules/call_scilab/examples/call_scilab/c/visual_studio/CallsciC.c
@@ -8,10 +8,10 @@
8#include <stdlib.h> 8#include <stdlib.h>
9#include <stdio.h> 9#include <stdio.h>
10#include <string.h> 10#include <string.h>
11#include "CallScilab.h" 11#include "call_scilab.h"
12#include "stack-c.h" 12#include "stack-c.h"
13/*--------------------------------------------------------------------------*/ 13/*--------------------------------------------------------------------------*/
14/* See SCI/modules/core/includes/CallScilab.h */ 14/* See SCI/modules/core/includes/call_scilab.h */
15/*--------------------------------------------------------------------------*/ 15/*--------------------------------------------------------------------------*/
16static int example1(void) 16static int example1(void)
17{ 17{
diff --git a/scilab/modules/call_scilab/examples/call_scilab/cpp/common/myprog.c b/scilab/modules/call_scilab/examples/call_scilab/cpp/common/myprog.c
index 466b56f..910262e 100644
--- a/scilab/modules/call_scilab/examples/call_scilab/cpp/common/myprog.c
+++ b/scilab/modules/call_scilab/examples/call_scilab/cpp/common/myprog.c
@@ -8,7 +8,7 @@
8#define FALSE 0 8#define FALSE 0
9 9
10/*--------------------------------------------------------------------------*/ 10/*--------------------------------------------------------------------------*/
11/* See routines/system/CallScilab.h */ 11/* See routines/system/call_scilab.h */
12extern int StartScilab(char *SCIpath,char *ScilabStartup,int *Stacksize); 12extern int StartScilab(char *SCIpath,char *ScilabStartup,int *Stacksize);
13extern int TerminateScilab(char *ScilabQuit); 13extern int TerminateScilab(char *ScilabQuit);
14extern int SendScilabJob(char *job); 14extern int SendScilabJob(char *job);
diff --git a/scilab/modules/call_scilab/help/en_US/ComplexManagement.xml b/scilab/modules/call_scilab/help/en_US/ComplexManagement.xml
index 900708d..6ef9d54 100644
--- a/scilab/modules/call_scilab/help/en_US/ComplexManagement.xml
+++ b/scilab/modules/call_scilab/help/en_US/ComplexManagement.xml
@@ -53,12 +53,25 @@
53 * Note that it is done column by column 53 * Note that it is done column by column
54 */ 54 */
55 55
56double B[]={1,3,4,9,2,8,3,2,1,0,-1,0,1/2,42,0,0}; /* Declare the matrix */ 56
57double B[]={1,3,4,9,2,8,3,2};
58double B_img[]={1,0.233,-1,-0.2,0.5,42,-23,123}; /* Declare the matrix */
59
60/*
61 * Prior to Scilab 5.2:
62 * double B[]={1,3,4,9,2,8,3,2,1,0.233,-1,-0.2,0.5,42,-23,123};
63*/
64
57int rowB=2, colB=4; /* Size of the matrix */ 65int rowB=2, colB=4; /* Size of the matrix */
58char variableNameB[] = "B"; 66char variableNameB[] = "B";
59 67
60C2F(cwritecmat)(variableNameB, &rowB, &colB, B, strlen(variableNameB)); /* Write it into Scilab's memory */ 68/* Write it into Scilab's memory */
69createNamedComplexMatrixOfDouble(pvApiCtx,variableNameB,rowB,colB, B, B_img);
61 70
71/*
72 * Prior to Scilab 5.2:
73 * 2F(cwritecmat)(variableNameB, &rowB, &colB, B, strlen(variableNameB));
74 */
62printf("\n"); 75printf("\n");
63printf("Display from Scilab of B:\n"); 76printf("Display from Scilab of B:\n");
64SendScilabJob("disp(B);"); /* Display B */ 77SendScilabJob("disp(B);"); /* Display B */
@@ -69,16 +82,28 @@ int rowB_ = 0, colB_ = 0, lp_ = 0;
69int i = 0,j = 0; 82int i = 0,j = 0;
70 83
71double *matrixOfComplexB = NULL; 84double *matrixOfComplexB = NULL;
85double *matrixOfComplexB_img = NULL;
72char variableToBeRetrievedB[] = "B"; 86char variableToBeRetrievedB[] = "B";
73 87
74/* First, retrieve the size of the matrix */ 88/* First, retrieve the size of the matrix */
75C2F(cmatcptr)(variableToBeRetrievedB, &rowB_, &colB_, &lp_, strlen(variableToBeRetrievedB)); 89readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, NULL, NULL);
90
91/*
92 * Prior to Scilab 5.2:
93 * C2F(cmatcptr)(variableToBeRetrievedB, &rowB_, &colB_, &lp_, strlen(variableToBeRetrievedB));
94 */
76 95
77/* Alloc the memory */ 96/* Alloc the memory */
78matrixOfComplexB = (double*)malloc((rowB_*colB_*2)*sizeof(double)); 97matrixOfComplexB = (double*)malloc((rowB_*colB_)*sizeof(double));
98matrixOfComplexB_img = (double*)malloc((rowB_*colB_)*sizeof(double));
79 99
80/* Load the matrix */ 100/* Load the matrix */
81C2F(creadcmat)(variableToBeRetrievedB,&rowB_,&colB_,matrixOfComplexB,strlen(variableToBeRetrievedB) ); 101readNamedComplexMatrixOfDouble(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, matrixOfComplexB, matrixOfComplexB_img);
102
103/*
104 * Prior to Scilab 5.2:
105 * C2F(creadcmat)(variableToBeRetrievedB,&rowB_,&colB_,matrixOfComplexB,strlen(variableToBeRetrievedB) );
106 */
82 107
83printf("\n"); 108printf("\n");
84printf("Display from B formated (size: %d, %d):\n",rowB_, colB_); 109printf("Display from B formated (size: %d, %d):\n",rowB_, colB_);
@@ -88,7 +113,8 @@ for(j = 0 ; j < rowB_ ; j++)
88 { 113 {
89 /* Display the formated matrix ... the way the user 114 /* Display the formated matrix ... the way the user
90 * expect */ 115 * expect */
91 printf("%5.2f + %5.2f.i ",matrixOfComplexB[i * rowB_ + j],matrixOfComplexB[(rowB_*colB_)+(i * rowB_ + j)]); 116 printf("%5.2f + %5.2f.i ",matrixOfComplexB[i * rowB_ + j],matrixOfComplexB_img[i * rowB_ + j]);
117
92 } 118 }
93 printf("\n"); /* New row of the matrix */ 119 printf("\n"); /* New row of the matrix */
94 } 120 }
diff --git a/scilab/modules/call_scilab/help/en_US/cwritecmat.xml b/scilab/modules/call_scilab/help/en_US/cwritecmat.xml
index 45d7be5..b3b858e 100644
--- a/scilab/modules/call_scilab/help/en_US/cwritecmat.xml
+++ b/scilab/modules/call_scilab/help/en_US/cwritecmat.xml
@@ -112,7 +112,7 @@
112 * Note that it is done column by column 112 * Note that it is done column by column
113 */ 113 */
114 114
115double B[]={1,3,4,9,2,8,3,2,1,0,-1,0,1/2,42,0,0}; /* Declare the matrix */ 115double B[]={1,3,4,9,2,8,3,2,1,0,-1,0,0.5,42,0,0}; /* Declare the matrix */
116int rowB=2, colB=4; /* Size of the matrix */ 116int rowB=2, colB=4; /* Size of the matrix */
117char variableNameB[] = "B"; 117char variableNameB[] = "B";
118 118