Matrix tutorials (9)

1 Name: #!/usr/bin/anonymous : 2007-11-13 15:35 ID:tiS7jB5u This thread was merged from the former /code/ board. You can view the archive here.

Hello, I was wondering if an of you would be so kind as to post an example of a matrix arrangement, or links to places where I can find good tutorials about the subject.

thanks in advance.

2 Name: #!/usr/bin/anonymous : 2007-11-13 16:16 ID:tiS7jB5u

Sorry. Non english speaker here. I meant "multi dimensional array".

bidimensional ones. Nothing too complex.

3 Name: #!/usr/bin/anonymous : 2007-11-13 22:50 ID:K+jWl6ob

A. It is correct to refer to a 2D array as a matrix in English, although it is a less commonly used term amongst programmers who lack the math-fu. Using the term matrix does indicate a non-jagged array. "Bidimensional", on the other hand, is definitely not a word. Only British people say silly things like that.

B. Fucking google it dude. Anyway, I'm bored so here's some very basic fun with matrices in MSVC++:

---snip---

#include "stdafx.h"
#include <stdlib.h>
// Size of one side of the matrix.
#define MATRIX_SIZE 20
void PrintIntegralMatrix(int matrix[MATRIX_SIZE][MATRIX_SIZE])
{
// Iterate outer array of arrays.
for(int i = 0;i < MATRIX_SIZE;i++)
{
// Iterate each inner array.
for(int ii = 0;ii < MATRIX_SIZE;ii++)
{
// Print the value at each
// index of the current
// inner array.
printf("%d ", matrix[i][ii]);
}
		// Print each inner array on a new
// line to give the appearance of
// a matrix.
printf("\n\r");
}
}
int _tmain(int argc, _TCHAR* argv[])
{
// Declare a matrix of integers on the stack.
int integralMatrix[MATRIX_SIZE][MATRIX_SIZE];
	// Fill the matrix with increasing values,
// starting at 0 for each row.
for(int i = 0;i < MATRIX_SIZE;i++)
for(int ii = 0;ii < MATRIX_SIZE;ii++)
integralMatrix[i][ii] = ii;
	// Print the matrix.
PrintIntegralMatrix(integralMatrix);
	system("pause");
	return 0;
}

4 Name: #!/usr/bin/anonymous : 2007-11-13 23:28 ID:tiS7jB5u

Thanks a lot =)

I DID fucking googled it, but all the examples I found (except one that lead me to a great page named cprogramming.com) were too complex for my needs. Besides, all of them showed up a lot of errors when compiled on Dev C++.

Yours didnĀ“t ^^

Thanks for the help.

5 Name: #!/usr/bin/anonymous : 2007-11-14 01:25 ID:NdmaD0AH

>>4
NP... glad it worked for you! I whipped it up at the office, where the only linux boxen are XenServers, and I was kinda worried you'd try running it through GCC or something.

You mentioned you're not a native english speaker... what is your first language? I might be willing to swap more programming help for linguistic instruction ;)

Also, notice that I declare the arrays on the stack. Don't do this with large data structures, especially in recursive functions or if the array sizes are variable. Use STL, passing by reference, and exception handling in those scenarios.

6 Name: #!/usr/bin/anonymous : 2007-11-14 02:38 ID:tiS7jB5u

Oh, dont worry, I REALLY dont think i will be using too large arrays.

My native is spanish, if you are interested.

7 Name: #!/usr/bin/anonymous : 2007-11-14 14:01 ID:NdmaD0AH

>>6
I would be interested if I hadn't been made to suffer through 3 years of uninspired Spanish instruction in High School. Thanks anyway.

8 Name: #!/usr/bin/anonymous : 2007-11-15 01:32 ID:tiS7jB5u

xD Is ok. Thanks to you.

9 Name: #!/usr/bin/anonymous : 2014-10-21 19:24 ID:Heaven

You have to wonder https://dis.4ct.org/lounge/read/1413901504 about fishing on the water

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: