Years ago I wrote a program in Fortran for a structural analysis class. At the time I had very little programming experience and mottled my way through the assignment. Fast forward to now and I'm attempting to teach myself Python 3. I figured I'd would try to convert the old program from Fortran to Python. I've made some good progress but I've hit a wall. I've got the program running to the point where all the element stiffness matrices are defined and combined into the structure stiffness matrix using the code number technique. The structure stiffness matrix is triangular. At … |
+0 forum
7 | ||

**A newbie would appreciate if someone could give him a pseudocode or any kind of explanation for the part of the code where the actual algorithm for matrix determinant is written.** using System; namespace Determinant { class Program { public static double DET(int n, double[,] Mat) { double d = 0; int k, i, j, subi, subj; double[,] SUBMat = new double[n, n]; if (n == 2) { return ((Mat[0, 0] * Mat[1, 1]) - (Mat[1, 0] * Mat[0, 1])); } else { for(k = 0; k<n; k++) { subi = 0; for(i = 1; i<n; i++) { subj = … |
+0 forum
3 | ||

Following is a matrix multiplication code written in MPI (Message Passing Interface) which could be run on CPU cluster for parallel processing. This has been successfully tested with two square matrices, each of the size 1500*1500. |
+2 forum
5 | ||

I have been learning NumPy arrays/matrices in Python. As I worked, I found that I desired a more readable form of 3d matrices. So I figured that writing one would be a good goal and learning exercise. The goal was to create a function that would print 3d NumPy matrices out in a more readable 'tower' form, but without altering the original matrix or duplicating it . I accomplished the goal, and learned much about NumPy, and output formatting. If you too desire to have 3d matrices displayed in a more readable form, then this should do the trick. Enjoy. … |
+0 forum
0 | ||

I am working on a multi-level marketing (matrix type) web application for a friend. I need assistance with a code snippet for generating a tree view of the downlines and the income calculations. The width is 3 and depth is 4. Thanks |
+0 forum
1 | ||

I've been here before but I'm looking to find a single-pass method to input the LRS `[[0,0,0],[0,0,0],[1,1,1]]` and get a basic 3x4 (at least) matrix in return: [ [1,0,0,0], [0,1,0,0], [0,0,1,0] ] ^ matrix is NOT transposed (I'll never understand why we use column-major) anyone got anything on this?? > I've been here before trust me, you don't want to see my current code. :P also, please don't provide math references such as wikipedia... I can read programming, not math. meaning I can read `v = sqrt( x )`, not: *insert math algorithm here* |
+0 forum
20 | ||

**Problems 1: Spiral matrix - Advanced** Source of the problem: [Here (not in English)](http://www.spoj.com/PTIT/problems/BCACM11B/) Spiral matrix is formed by filling number 1 in 1st row 1st column, after that, filling with increasing number by clockwise, example: 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 Write a program that inform the value of cell (x, y) of a square spiral matrix sized n x n. *Input:* First row record the number of tests, not greater than 100. Each test record in one row, include … |
+0 forum
1 | ||

For my own use, I'd like to develop a small Vector and a Matrix class, independent of some big libraries that exist out there. My question is: Should Vector and Matrix stay two independent entities or should I derive a Vctor frm a Matrix or a Matrix from a Vector? Any response is as always greatly appreciated. :) |
+0 forum
9 | ||

I wan to wirte in cout << ... to have the matrix in output in the same format that I wrote it in text file like this: 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 class Classname { double data[3][3]; public: void Read(char *fname); void Writedata(); } void Classname::Read(char *fname) { int i, j; ifstream fin(fname); fin >> 3; // read the matrix for(i= 0; i<3; i++) for(j= 0; j<3; j++) fin >> data[i][j]; } void Classname::Writedata(char *fname) { // writes model to cout in same format it was read in cout << … |
+0 forum
6 | ||

I have a 1000x24 matrix in a text file and i want to sum the adjoining columns of the whole matrix e.g. col1+col2, col2+col3, col3+col4,... col23+col24 and store these values in a separate text file. My code runs like this: #include <stdio.h> int main() { int i,j; float a[100][24]; FILE *fp=fopen("D:\1980.txt","r"); FILE *fp1=fopen("D:\\sum.txt","w"); for (i=0;i<=99;i++) { for (j=0;j<=23;j++) { a[i][j]= a[i][j]+a[i][j+1]; } } for(i=0;i<=999;i++) { for(j=0;j<=23;j++) { fprintf(fp1,"%.2f\t",a[i][j]); fprintf(fp1,"\n"); } } fclose(fp); fclose(fp1); getch(); } for example if a matrix in file 1980.txt is like [1 2 3;4 5 6;7 8 9], the output in sum.txt should be [3 5;9 … |
+0 forum
1 | ||

I was doing the class tutorial to have matrix multiplication from two dimensional arrays: X (3x2) and Y (2x3). package t7; public class Q5 { public static void main(String[] args) { int[][] matrix_X = new int [3][2]; int[][] matrix_Y = new int [2][3]; int[][] result = new int [3][3]; for (int i=0; i<matrix_X.length; i++) { for(int j=0; j<matrix_X[i].length; j++) { matrix_X[i][j] = (int)(Math.random() * 100); matrix_Y[i][j] = (int)(Math.random() * 100); } } System.out.println("Matrix X is:"); printMatrix(matrix_X); System.out.println("Matrix Y is:"); printMatrix(matrix_Y); result = multiplyMatrix(matrix_X, matrix_Y); } public static void printMatrix(int[][] m) { for (int i=0; i<m.length; i++) { for (int j=0; … |
+0 forum
2 | ||

Hello, So I was testing my matrix class and the results look questionable and the inverted matrix isn't returning the vertex to it's original value (a seperate issue). Given a perspective projection at 45 degrees with a near of 1 and a far of 1000, the camera at the orgin looking down z and a vertext along z axis at 0, 1 and 1000, What would their resulting depths be? |
+0 forum
10 | ||

Hello, guys, I encountered a big problem. There is a genereted matrix of buttons: private void Single_Load(object sender, EventArgs e) { //code here for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { //a lot of working code here b[i, j].Click += new System.EventHandler(ClickButton); } } } What can I do when one of those buttons is pressed (i have the method `ClickButton`) to know what *i* and *j* has he? I want to make smoething like this ClickButton() { if (x%2==0) v[i, j] = x; //i and j should … |
+1 forum
2 | ||

Hello all! Can someone help with this matrix? it needs to spiral inwards, from bottom right corner, clockwise... I found this code... and it runs nicely but I need to adapt it in some ways: - I should be able to provide number of rows and columns - the grid should start from number 1 - it should start from bottom right corner, clockwise... I will put the code that works, but not the way I need... can someone at least decipher it for me so I could try to do it?? Thanks <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled … |
+0 forum
1 | ||

This Project is to implement some procedures doing the following: 1. Represent any graph using these input parameters: • A parameter to represent the graph by Adjacency Matrix, or Adjacency List. • A parameter to indicate whether the graph is directed, or undirected. • A parameter to indicate whether the graph is wieghted, or unweighted 2. Traverse the graph nodes and list them using both BFS, and DFS algorithms. 3. Determine the MST of any input graph, using Prim’s or Kruskal’s algorithm. 4. Implement Dijkstra’s algorithm to find the shortest path from a given vertex to all other vertices. 5. … |
+0 forum
0 | ||

Code Snippet
Optimizing Matrix Multiplication Optimizing Matrix Multiplication One time consuming task is multiplying large matrices. In this post we'll look at ways to improve the speed of this process. We'll be using a square matrix, but with simple modifications the code can be adapted to any type of matrix. The straight forward way to multiply a matrix is: [code]for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { for (int k = 0; k < N; k++) { C[i,j] += A[i,k] * B[k,j]; } } }[/code] Now it's not important to us in which … |
+7 forum
11 | ||

I have a base class called Matrix which has a function transpose. I also have a derived class Matrix2 which is inherited publicly from Matrix class Matrix { public: Matrix(); ... Matrix Transpose(void); ... }; class Matrix2 : public Matrix { public: Matrix2(); ... }; In my main code, I tried this. vector <Matrix2> myMatrix2; vector <Matrix> *b = &myMatrix2; to do this b->transpose(); But I get the following error `error C2440: 'initializing' : cannot convert from 'std::vector<_Ty> *' to 'std::vector<_Ty> *'` What is wrong... What is the way to access the transpose function from Matrix class in vector? I … |
+0 forum
2 | ||

This is really simple. Just take the last letter of the movie name in previous post & put another movie name starting with that letter. Eg.:- if i put "The Matrix -Reloaded" answer may be "Doom" so let's start. I put : The Matrix Revolution |
+0 forum
564 | ||

Hi, I have an assignment. I need to write code in logic programming language SWI-Prolog. Its very hard and I am going to appreciate if you help me :D. This is the assigment: Print 2D array size of (width x height) in spiral order. More explanation and example: You have input, width and height that are integers. With this input program needs to print a matrix "spiral" of numbers, from 1 to (height x width). Height is size of column in "spiral" matrix Width is size of row in "spiral" matrix This is just an example: spiralmatrix(w,h). /*w - width, … |
+0 forum
2 | ||

Hello, So I'm aware that OpenGL is Column major and DirectX is Row major, but how does that translate into a basic 1D array? So given the below visual matrix, what would the first 3 in the array of each platform and which 3 would be the x,y and z translation of each platform? |AA BA CA DA| |AB BB CB DB| |AC BC CC DC| |AD BD CD DD| What I'm trying to find out is if I was given a matrix pulled from either platforms, would a formula for one work with the other (x,y,z translation index stay … |
+0 forum
4 | ||

I have an mxn matrix, that is stored in memory in an array: matA = new float[m * n]; // ... Assign values matA[0] = 1; matB[1] = 2; // ... After I finish with this array, I then need to create very similar array to store a new mxn matrix--the same matrix as before, but with each column shifted to the right. Let's call it matB. Am I better of to create a new matrix? matB = new float[m * n]; // ... Assign values matB[0] = 23; matB[1] = 1; matB[2] = 2; // ... Or is there … |
+0 forum
4 | ||

Hi, I'm a beginner with Java, can anyone tell me where my error is, I'm sure there's something I'm missing here with the array logic: public void scalarMultiplication(int c) { for( int i=0; i <values.length - 1;i++){ for(int j=0; j < values.length - 1;j++){ values[i][j] = values[i][j] * c; } main: Matrix n = new Matrix(new int[][] { { 1, 0, -1 }, { 1, 3, 3 }, { -2, -4, 1 }, { 0, 0, 1 } }); n.scalarMultiplication(-1); my output: [-1, 0, 1] [-1, -3, -3] [2, 4, -1] [0, 0, 1] *The lost row of the matrix … |
+0 forum
1 | ||

I was wondering if there is any way to do a single mysql query to do a count of filled positions in a multi-level structure to an indefinite depth. That sounds a bit cryptic, but this is what I would like to do if it is at all possible. we are working within a 3 x ___ matrix meaning level 1 has 3 positions level 2 has 9 positions level 3 has 27 positions and so on... If a sponsor wants to know how many positions are filled within his downline I would like to be able to provide that … |
+0 forum
5 | ||

can any body please tell me that how to take input size of a matrix in 2 d array an then print the table of it.... sample output 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25 |
+0 forum
2 | ||

please help me i need a dynamic array that get the information as a matris and give me the vertex degrees (sum every row).and send it to another matrix. #include "stdafx.h" #include<conio.h> #include<iostream> #include <stdlib.h> #include <string.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int k,sum; cout << "Enter the Graph vertex number: "; cin >> k; int i, j, *a, b[100]; a = new int [i][j]; cout << "your Gragh is" << k << " , " << k << ", enter your numbers:"<< endl; for (i = 0; i<k; i++) { for (j = 0; j<k; … |
+0 forum
9 | ||

I need to write a code that is gonna remove a whole row/column in a matrix(either static or dynamic matrix) |
+0 forum
6 | ||

Write a program that can do the following: addition of two matrices . subtraction of two matrices. multiplication of a matrix by a scalar. multiplication of a matrix by a matrix. |
+0 forum
1 | ||

Code Snippet
Spiral Order Of Matrix This Program prints the numbers in given array(Row-Major Order) in Spiral order. Ex: Order Is 3*4 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Spiral Order Of Matrix is 11 12 13 14 18 22 26 25 24 23 19 15 16 17 21 20 |
+0 forum
3 | ||

I cant figure out how to check the array for AND and OR. please, help, i got stuck my code: import java.util.Scanner; public class BooleanProduct import java.util.Scanner; public class BooleanProduct { public static void main(String[] args) { Scanner input = new Scanner(System.in); int[][] A = new int[10][10]; int[][] B = new int[10][10]; int[][] C = new int[10][10]; int m,n,p,q; System.out.println("Enter number of rows for matrix A : "); m = input.nextInt(); System.out.println("Enter number of columns for matrix A : "); n = input.nextInt(); System.out.println("Enter number of rows for matrix B : "); p = input.nextInt(); System.out.println("Enter number of columns for … |
+0 forum
3 | ||

import java.util.Scanner; public class BooleanProduct { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = 10; int[][] A = new int[n][n]; int[][] B = new int[n][n]; //Fill A and B int m,n2,p,q; System.out.println("Enter number of rows for matrix A : "); m = input.nextInt(); System.out.println("Enter number of columns for matrix A : "); n2 = input.nextInt(); System.out.println("Enter number of rows for matrix B : "); p = input.nextInt(); System.out.println("Enter number of columns for matrix B : "); q = input.nextInt(); System.out.println("Enter elements for matrix A (by rows): "); for (int i=0 ; i < m … |
+0 forum
4 |

The End.