The Easiest Way to Save and Share Code Snippets on the web

Your snipt has been migrated to #newsnipt successfully.

Hello World

cpp

last edit: Jun, 30th 2010 | jump to bottom

#include <itpp/itbase.h>
 
using namespace itpp;
using namespace std;
 
int main()
{
    mat matrizA;                        	// Declara uma matriz A
    mat matrizB;                        	// Declara uma matriz B
    mat matrizC;                        	// Declara uma matriz C
 
    matrizA = zeros(3,3);			// A = [0 0 0; 0 0 0; 0 0 0]
    matrizB = "1 2 3; 4 5 6; 7 8 9";	// B = [1 2 3; 4 5 6; 7 8 9]
    matrizC = matrizA + matrizB;	// C = [1 2 3; 4 5 6; 7 8 9]
 
    cout << matrizC << endl;		// Imprime o resultado
 
    vec vetorX;					// Declara um vetor X
    vec vetorY;					// Declara um vetor Y
 
    vetorX = "10 20 30 40 50";		// X = [10 20 30 40 50]
    vetorY = matrizB.get_row(1);	// Y = [4 5 6]
 
    cout << vetorY << endl;		// Imprime o resultado
 
    cout << "fim";				// The End
    return 0;
}
30 views