File: multiply_by_two.c

package info (click to toggle)
scilab 5.5.1-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 337,804 kB
  • ctags: 69,618
  • sloc: xml: 770,056; ansic: 295,010; java: 187,293; fortran: 155,805; cpp: 66,211; ml: 24,230; sh: 23,700; tcl: 14,792; makefile: 8,315; perl: 1,566; php: 690; cs: 614
file content (30 lines) | stat: -rwxr-xr-x 816 bytes parent folder | download | duplicates (7)
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
#include <stack-c.h>

int sci_multiply_by_two(char * fname)
{
    int m_in_var, n_in_var, l_in_var;
    int m_out_var, n_out_var, l_out_var;
    int i_row, j_col;

    // First, access to the input variable (a matrix of doubles)
    GetRhsVar(1, "d", &m_in_var, &n_in_var, &l_in_var);

    // Create the returned variable (a matrix of doubles)
    m_out_var = m_in_var;
    n_out_var = n_in_var;
    CreateVar(2, "d", &m_out_var, &n_out_var, &l_out_var);

    // Perform some simple operations on the matrix
    for (i_row = 0; i_row < m_in_var; i_row++)
    {
        for (j_col = 0; j_col < n_in_var; j_col++)
        {
            *stk(l_out_var + i_row + j_col * m_out_var) = 2 * (*stk(l_in_var + i_row + j_col * m_in_var));
        }
    }

    // Return the output variable
    LhsVar(1) = 2;

    return 0;
}