File: BooleanManagement.xml

package info (click to toggle)
scilab 5.5.2-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 339,404 kB
  • ctags: 71,193
  • sloc: xml: 766,922; ansic: 295,260; java: 187,853; fortran: 155,904; cpp: 67,546; ml: 24,107; sh: 23,715; tcl: 14,792; makefile: 8,328; perl: 1,566; php: 690; cs: 614
file content (156 lines) | stat: -rw-r--r-- 5,583 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2009  - DIGITEO - Sylvestre LEDRU
 * 
 * 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.1-en.txt
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="BooleanManagement_callscilab" xml:lang="en">
    <refnamediv>
        <refname>Boolean management</refname>
        <refpurpose>How to manage Scilab's boolean read and write process using
            call_scilab and api_scilab
        </refpurpose>
    </refnamediv>
    <refsection>
        <title>Description</title>
        <para>This help describes how boolean and matrix of booleans can be handle
            through the <link linkend="call_scilab">Call Scilab API</link> and <link linkend="api_scilab">api Scilab</link>.
        </para>
        <para>There are several functions which can be used to read / write from
            the memory of Scilab. These functions are described in dedicated
            pages.
        </para>
        <para>
            <note>
                Note: Access to variables is done through <link linkend="api_scilab">api Scilab</link> (named variable).
            </note>
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[ 
/* 
 * Write a matrix of boolean into Scilab
 * B=[F F T F; 
 *    F F F T ]
 * Note that it is done column by column
 */ 
int B[]={0,0,0,0,1,0,0,1};   /* Declare the matrix */
int rowB=2, colB=4; /* Size of the matrix */
char variableNameB[] = "B";
SciErr sciErr;

/* Write it into Scilab's memory */
sciErr = createNamedMatrixOfBoolean(pvApiCtx, variableNameB, rowB, colB, B);
if(sciErr.iErr)
{
	printError(&sciErr, 0);
}

/*
 * Prior to Scilab 5.2:
 * C2F(cwritebmat)(variableNameB, &rowB, &colB, B, strlen(variableNameB)); 
 */

printf("Display from Scilab of B:\n");
SendScilabJob("disp(B);"); /* Display B */
 ]]></programlisting>
        <programlisting role="example"><![CDATA[ 
/* Read the previously declared matrix of boolean B */
int rowB_ = 0, colB_ = 0, lp_ = 0;
int i = 0, j = 0;
int *matrixOfBooleanB = NULL; /* Int instead of double */

char variableToBeRetrievedB[] = "B";
SciErr sciErr;
/* First, retrieve the size of the matrix */
sciErr = readNamedMatrixOfBoolean(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, NULL);
if(sciErr.iErr)
{
	printError(&sciErr, 0);
}

/*
 * Prior to Scilab 5.2:
 * C2F(cmatbptr)(variableToBeRetrievedB, &rowB_, &colB_, &lp_, strlen(variableToBeRetrievedB));
 */

/* Alloc the memory */
matrixOfBooleanB=(int*)malloc((rowB_*colB_)*sizeof(int));

/* Load the matrix */
sciErr = readNamedMatrixOfBoolean(pvApiCtx, variableToBeRetrievedB, &rowB_, &colB_, matrixOfBooleanB);
if(sciErr.iErr)
{
	printError(&sciErr, 0);
}

/*
 * Prior to Scilab 5.2:
 * C2F(creadbmat)(variableToBeRetrievedB,&rowB_,&colB_,matrixOfBooleanB,strlen(variableToBeRetrievedB) );
 */

printf("\n");
printf("Display from B formated (size: %d, %d):\n",rowB_, colB_);
for(j = 0 ; j < rowB_ ; j++)
{
 for(i = 0 ; i < colB_ ; i++)
 {
  /* Display the formated matrix ... the way the user expects */
  printf("%d ",matrixOfBooleanB[i * rowB_ + j]);
 }
 printf("\n"); /* New row of the matrix */
}
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See Also</title>
        <simplelist type="inline">
            <member>
                <link linkend="api_scilab">api Scilab</link>
            </member>
            <member>
                <link linkend="call_scilab">call_scilab</link>
            </member>
            <member>
                <link linkend="boolean_reading_API">API_Scilab: Boolean reading</link>
            </member>
            <member>
                <link linkend="boolean_writing_API">API_Scilab: Boolean writing</link>
            </member>
            <member>
                <link linkend="SendScilabJob">SendScilabJob</link>
            </member>
            <member>
                <link linkend="StartScilab">StartScilab</link>
            </member>
            <member>
                <link linkend="DoubleManagement_callscilab">Call_Scilab: Double Management</link>
            </member>
            <member>
                <link linkend="ComplexManagement_callscilab">Call_Scilab: Complex Management</link>
            </member>
            <member>
                <link linkend="StringManagement_callscilab">Call_Scilab: String Management</link>
            </member>
            <member>
                <link linkend="Double_management_reading_API">API_Scilab: Double Reading</link>
            </member>
            <member>
                <link linkend="Double_management_writing_API">API_Scilab: Double Writing</link>
            </member>
            <member>
                <link linkend="String_management_reading_API">API_Scilab: String Reading</link>
            </member>
            <member>
                <link linkend="String_management_writing_API">API_Scilab: String Writing</link>
            </member>
        </simplelist>
    </refsection>
</refentry>