[ 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:


int a[11] ;
int b[11] ;

for( int i=0; i<=10; i=i+1 ){

	a[i] = i * i ;
	b[i] = i ;

}


int c[11] ;

c = a + b ;  // Vector addition here

print ( c[5] );
SIMDAddition.vcssl

- 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.


Author of This Article

Fumihiro Matsui
[ Founder of RINEARN, Doctor of Science (Physics), Applied Info Tech Engineer ]
Develops VCSSL, RINEARN Graph 3D and more. Also writes guides and articles.

Translation Cooperator

ChatGPT AIs
[ GPT-3.5, 4, 5, 5.1 ]
We greatly appreciate the cooperation of ChatGPT AIs in translating this article.


Sponsored Link



Index
News From RINEARN
* VCSSL is developed by RINEARN.

Exevalatorv2.4Released—MCPSupportAdded,NowUsableasanAICalculationTool
2025-11-15 - We'vereleasedExevalatorv2.4,ourexpression-evaluationlibrary.Startingwiththisversion,itsupportsMCP,makingitusableasacalculationtoolforAIassistants.

Exevalatorv2.3Released—NowUsablefromPython
2025-11-04 - We'vereleasedExevalatorv2.3.Startingwiththisversion,youcannowuseitfromPython!WithgrowingdemandaroundAItooldevelopmentinmind,wesharethedetailshere.

ExevalatorUpdated—EasyJapaneseLocalizationforErrorMessages
2025-10-31 - Exevalator2.2.2isout.YoucannowlocalizeerrormessagestoJapanesewithasimplecopy-and-paste,andwe'veincludedseveralbugfixesandminorparseradjustments.

InsideRINPnOnline:ArchitectureOverview
2025-10-22 - AninsidelookatthearchitectureoftherecentlylaunchedonlineversionoftheRINPnscientificcalculator.It'sopensource,soyoucanfreelymodifyandreuseittobuildyourownwebcalculator(maybe!).

MeetRINPnOnline:UsetheScientificCalculatorAnywhere,Instantly
2025-10-21 - RINPn,thefreescientificcalculator,nowhasanonlineversionyoucanuseinstantlyinyourbrowser—onbothPCandsmartphones.Readtheannouncementfordetails.

TheVCSSLSupportAIisHere!—RequiresaChatGPTPlusAccountforPracticalPerformance
2025-08-19 - AnewAIassistantfortheVCSSLprogramminglanguageisheretoansweryourquestionsandhelpwithcoding.ThisarticleexplainshowtouseitandshowcasesplentyofrealQ&Aandgeneratedcodeexamples.

EnglishDocumentationforOurSoftwareandVCSSLIsNowNearlyComplete
2025-06-30 - We'rehappytoannouncethatthelarge-scaleexpansionofourEnglishdocumentationwiththesupportofAI—aprojectthatbegantwoyearsago—hasnowreacheditsinitialtargetmilestone.

VCSSL3.4.52Released:EnhancedIntegrationwithExternalProgramsandMore
2025-05-25 - Thisupdateintroducesenhancementstotheexternalprogramintegrationfeatures(e.g.,forrunningC-languageexecutables).Severalotherimprovementsandfixesarealsoincluded.Detailsinside.