[ Prev | Index | Next ]

# Vector Operations

In this section, we'll discuss vector operations, which involve operations between arrays.

## Vector Operations

VCSSL supports vector operations, enabling the same operation to be applied uniformly across all elements of operand arrays.

To perform vector operations, excluding the plain assignment operation "=", it's generally required that the dimensions and sizes of all array variables in the expression are the same. Additionally, non-array variables can be included in expressions, and in such cases, they are treated as if they were arrays storing the same value for all elements.

## Operators Supporting Vector Operations

Vector operations are supported by most operators, including:

• Arithmetic Operators: +, -, *, /, %, **, ++, --
• Comparison Operators: <, >, <=, >=, ==, !=
• Logical Operators: &&, ||, !
• Assignment and Compound Assignment Operators: =, +=, -=, *=, /=, %=

These operators automatically engage in vector operations whenever the operands (*) are arrays.

* Values or variables involved in the operation, e.g: a and b in "a + b".
Size Restrictions for Assignment and Compound Assignment Operators

There is difference between size restrictions of assignment operations and compound assignment operations.

• Assignment Operators: "=" allows for assigning values from one array to another, resizing the destination array if necessary to match the source array's size. This operation is unique in that it can handle arrays of differing sizes by adjusting the destination array accordingly.
• Compound Assignment Operators: "+=", "-=", "*=", "/=", "%=" require that the dimensions and sizes of all array variables involved in the operation are the same, similar to arithmetic operators.

## Performing Addition with Vector Operations

Let's actually perform addition using vector operations:

- Execution Result -

30

When executed, it displays 30. Let's break down the process since it's a bit lengthy.

First, arrays "a" and "b" with 11 elements each are initialized. a is assigned the square of integers from 0 to 10, and b is assigned integers from 0 to 10 directly. Then, an array c with 11 elements is created.

Next, the line "c = a + b" executes vector addition. This operation assigns the following values to c:

c[0] = a[0] + b[0] ;
c[1] = a[1] + b[1] ;

c[10] = a[10] + b[10] ;

という内容が代入されます。

Finally, the function to print c[5] is called, and the program ends.

For c[5], it contains a[5] + b[5], which is 25 + 5, hence the output value of 30 as expected. This confirms that vector addition was successfully performed.

Acknowledgement: We greatly appreciate the cooperation of two ChatGPT AIs in translating this page.

[ Prev | Index | Next ]
Index
[ Prev | Index | Next ]
News

Software Updates: Command Expansion in RINEARN Graph, and English Support in VCSSL
2024/02/05 - We updated our apps. This updates include "Enhancing the Command-Line Features of RINEARN Graph" and "Adding English Support to VCSSL." Delves into each of them!

Inside the Repetitive Execution Speedup Impremented in Vnano Ver.1.1
2024/01/17 - Delves into the update in Vnano 1.1 from a developer's viewpoint, providing detailed insights into the specific improvements made to the internal structure of the script engine.

Scripting Engine Vnano Ver.1.1 Released: Dramatic Speed Improvement for Repetitive Executions of the Same Content
2023/12/22 - Released the Vnano script engine Ver.1.1. In this version, we've made significant enhancements in processing speed by reducing the overhead of handling requests. Explains the details.

Updated Contents
 Circular Wave Animation Draws the circular wave as 3D animation, under the specified wave parameters. 2022-12-14 Sine Wave Animation Draws the sine wave as animation, under the specified wave parameters. 2022-11-26 Tool For Converting Units of Angles: Degrees and Radians A GUI tool for converting the angle in degrees into radians, or radians into degrees. 2022-11-22 Connector Fatal Exception - Specification The unchecked exception thrown when errors have occurred, caused by incorrect implementations (might be bugs). 2022-09-26 Connector Exception - Specification The checked exception thrown when errors have occurred, cause by expected normal problems. 2022-09-26