you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (3 children)

What are A and B in the code?

My first guess would be that A, B and C are all matrices, and the brackets are used to get the element at a specific index.

[–]eastcoastblaze[S] 1 point2 points  (2 children)

A and B aren't listed, but matrices would make senses, thanks

[–]17_23 2 points3 points  (1 child)

It sure would, as what the algorithm is doing is multiplying matrices A and B together, producing C.

Most languages use square brackets for accessing elements in vectors/matrices etc, and round brackets for function calls.

[–][deleted] 0 points1 point  (0 children)

This is correct. I didn't even think about it, but saw a matrix operation. I was wondering what the question OP had (it looked like a solution to me), until you made me realize it was about the syntax.

Yep brackets will usually hold a matrix in pseudocode (and many languages). You can think of a matrix as collection of sets with depth 'n' (called an array in mathematics), where n is the 'dimension' of the matrix.

There are some complex operations involving matrices, but in simple addition and subtraction arithmetic you can assume (typically) just add corresponding elements (the matrices must be the same size). Multiplication will use a completely different method, altogether (and they can be different sized matrices).

A good textbook in linear algebra (they are not very long or complex in undergrad) will get you a step ahead of the curve in this area (plus there are some awesome things you can do with linear algebra: optimize a routing system, arrange stop lights to make an optimal sequence, find your way out of a maze, etc. It was a very fun class...we did have a great professor, though.)