Exemplo n.º 1
0
void multiplication_interface(){
	/* Interface to calculate matrix multiplication */
	int matrix1_rows, matrix1_columns, matrix2_rows, matrix2_columns;

	printf("Matrix 1 number of rows have to be equal to matrix 2 number of columns.");
	printf("Insert how many lines matrix 1 have: ");
	scanf("%d", &matrix1_rows);
	printf("Insert how many columns matrix 1 have: ");
	scanf("%d", &matrix1_columns);
	printf("\nInsert how many lines matrix 2 have: ");
	scanf("%d", &matrix2_rows);
	printf("Insert how many columns matrix 2 have: ");
	scanf("%d", &matrix2_columns);
	
	bool check_matrix = verify(1, matrix1_rows, matrix1_columns, matrix2_rows, matrix2_columns);
	if(check_matrix == true){
		int i, j;
		float item;
		
		printf("\nThe result will be %dx%d\n", matrix1_rows, matrix2_columns);
		printf("MATRIX 1 (%dx%d)\n", matrix1_rows, matrix1_columns);
		double (**matrix1) = createNewMatrix(matrix1_rows, matrix1_columns);
		printf("\nMATRIX 2 (%dx%d)\n", matrix2_rows, matrix2_columns);
		double (**matrix2) = createNewMatrix(matrix2_rows, matrix2_columns);
		printf("The result matrix is:\n");
		double (**result) = matricial_multiplication(matrix1, matrix2, matrix1_rows, matrix1_columns, matrix2_rows, matrix2_columns);
		print_matrix(matrix1_rows, matrix2_columns, result);
	}else{
		printf("There is an error with your input data.\nCheck them please.\n");
	}
}
Exemplo n.º 2
0
void sum_interface(int type){
	/*
	 * Interface to add or subtract matrices.
	 * - Type 0 --> Add
	 * - Type 1 --> Subtract
	 *
	 */
	int rows, columns;
	
	printf("Insert how many lines your matrix have: ");
	scanf("%d", &rows);
	printf("Inert how many columns your matrix have: ");
	scanf("%d", &columns);
	
	bool check_matrix = verify(0, rows, columns, 0, 0);
	if(check_matrix == true){
		int i, j;
		float item;

		printf("\nInsert item %dx%d of matrix 1\n", rows, columns);
		double (**matrix1) = createNewMatrix(rows, columns);
		printf("\nInsert item %dx%d of matrix 2\n", rows, columns);
		double (**matrix2) = createNewMatrix(rows, columns);
		printf("The result matrix is:\n");
		double (**result) = sum_matrices(matrix1, matrix2, rows, columns, type);
		print_matrix(rows, columns, result);
		
	}else{
		printf("There is an error with your input data.\nCheck them please.\n");
	}
}
Exemplo n.º 3
0
MatrixSelector::MatrixSelector(QWidget *parent) : QWidget(parent) {
  setupUi(this);

  _newMatrix->setIcon(QIcon(":/kst_matrixnew.png"));
  _editMatrix->setIcon(QIcon(":/kst_matrixedit.png"));

  _provideNoneMatrix = false;

  update();

  connect(_matrix, SIGNAL(activated(const QString&)), this, SIGNAL(selectionChanged(const QString&)));
  connect(this, SIGNAL(selectionChanged(QString)), this, SLOT(selectionWatcher(QString)));
  connect(_editMatrix, SIGNAL(clicked()), this, SLOT(editMatrix()));
  connect(_newMatrix, SIGNAL(clicked()), this, SLOT(createNewMatrix()));
}
Exemplo n.º 4
0
/* Interactive interface */
void determinant_interface(){
	/* Interface to calculate determinant */
	int size;

	printf("Insert how many line/columns your matrix have: ");
	scanf("%d", &size);
	
	bool check_matrix = verify(2, size, size, 0, 0);
	if(check_matrix = true){
		double (**matrix) = createNewMatrix(size, size);
		print_matrix(size, size, matrix);
		double det = determinant(matrix, size);
		printf("\nThe determinant is: %lf\n", det);
	}else{
		printf("There is an error with your input data.\nCheck them please.\n");
	}
}
Exemplo n.º 5
0
void transpose_interface(){
	int rows, columns;
	
	printf("Insert how many lines your matrix have: ");
	scanf("%d", &rows);
	printf("Inert how many columns your matrix have: ");
	scanf("%d", &columns);
	
	bool check_matrix = verify(2, rows, columns, 0, 0);
	if(check_matrix == true){
		int i, j;
		float item;
		double (**matrix) = createNewMatrix(rows, columns);
		double (**result) = transpose(matrix, rows, columns);
		print_matrix(columns, rows, result);
	}else{
		printf("There is an error with your input data.\nCheck them please.\n");
	}
}
Exemplo n.º 6
0
void inverse_interface(){
	int size;

	printf("Insert how many line/columns your matrix have: ");
	scanf("%d", &size);
 
	bool check_matrix = verify(0, size, size, 0, 0);
	if(check_matrix == true){
		double (**matrix) = createNewMatrix(size, size);
		if(determinant(matrix, size) != 0.0){
			double (**result) = inverse_matrix(matrix, size);
			printf("The inverse matrix is:\n");
			print_matrix(size, size, result);
		}else{
			printf("Your matrix do not have an inverse\n");
		}
	}else{
		printf("There is an error with your input data.\nCheck them please.\n");
	}
}
Exemplo n.º 7
0
void scalar_multiplication_interface(){
	int rows, columns;
	float scalar;
	
	printf("Type the scalar number: ");
	scanf("%f", &scalar);
	printf("Insert how many lines your matrix have: ");
	scanf("%d", &rows);
	printf("Inert how many columns your matrix have: ");
	scanf("%d", &columns);
	
	bool check_matrix = verify(2, rows, columns, 0, 0);
	if(check_matrix == true){
		int i, j;
		float item;

		double (**matrix) = createNewMatrix(rows, columns);
		double (**result) = scalar_multiplication(matrix, rows, columns, scalar);
		print_matrix(rows, columns, result);
	}else{
		printf("There is an error with your input data.\nCheck them please.\n");
	}
}