Click here to Skip to main content
16,007,126 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WSA Error 10038 - Veeery strange... Pin
DKT_1-May-05 1:08
DKT_1-May-05 1:08 
GeneralDriver Project in Visual C++ Pin
Anonymous28-Apr-05 21:18
Anonymous28-Apr-05 21:18 
GeneralRe: Driver Project in Visual C++ Pin
ThatsAlok28-Apr-05 21:25
ThatsAlok28-Apr-05 21:25 
GeneralRe: Driver Project in Visual C++ Pin
Alexander M.,29-Apr-05 9:06
Alexander M.,29-Apr-05 9:06 
Generalavi from sequence jpeg files Pin
hausen28-Apr-05 21:09
hausen28-Apr-05 21:09 
GeneralRe: avi from sequence jpeg files Pin
ThatsAlok28-Apr-05 21:17
ThatsAlok28-Apr-05 21:17 
GeneralRe: avi from sequence jpeg files Pin
Ted Ferenc28-Apr-05 21:33
Ted Ferenc28-Apr-05 21:33 
GeneralHelp with 2d-array multiplication Pin
aaadetos28-Apr-05 21:04
aaadetos28-Apr-05 21:04 
I can't figure why the following matrix multiplication isn't working. Can someone please help me?
<br />
// Q2_new.cpp : Defines the entry point for the console application.<br />
//<br />
<br />
#include <math><br />
#include "stdafx.h"<br />
#include <iostream><br />
using namespace std;<br />
<br />
double theta, phi, t, p;	//azimuth and dip angles respectively<br />
double lambda1 = 0.5;<br />
double lambda2 = 2;<br />
double a11,a12,a21,a22,d11,d13,d31,d33;<br />
const double pi = 3.142857;<br />
const int rows = 3;<br />
const int cols = 3;<br />
<br />
void mult(double *fr_array2);<br />
<br />
<br />
//---------------------------------------------------------<br />
//Initializing the arrays to zero<br />
//---------------------------------------------------------<br />
	//array that holds the dip angle, phi<br />
	double dip_array [3][3] = {0};	<br />
<br />
	//array that holds the azimuth angle, theta<br />
	double azim_array [3][3] = {0};	<br />
<br />
	//array that holds the anisotropy ratios<br />
	double lambda_array [3][3] = {0};	<br />
<br />
	//array that holds the original range values<br />
	double r_array [3] = {0};<br />
<br />
	//array that holds final range values<br />
	double fr_array [3][3] = {0};	<br />
<br />
	//array that holds final range values<br />
	double fr_array2 [3] = {0};	<br />
<br />
<br />
<br />
//---------------------------------------------------------<br />
//Code to convert the angles to radians, acceptable in C++<br />
//---------------------------------------------------------<br />
//Dip Angle,p<br />
double a(double p)<br />
{<br />
	d11 = cos((p*pi)/180);<br />
	return d11;<br />
}<br />
<br />
double b(double p)<br />
{<br />
	d13 = -1*sin((p*pi)/180);<br />
	return d13;<br />
}<br />
<br />
double c(double p)<br />
{<br />
	d31 = sin((p*pi)/180);<br />
	return d31;<br />
}<br />
<br />
double d(double p)<br />
{<br />
	d33 = cos((p*pi)/180);<br />
	return d33;<br />
}<br />
<br />
<br />
//Azimuth Angles, t<br />
double e(double t)<br />
{<br />
	a11 = sin((t*pi)/180);<br />
	return a11;<br />
}<br />
<br />
double f(double t)<br />
{<br />
	a12 = cos((t*pi)/180);<br />
	return a12;<br />
}<br />
<br />
double g(double t)<br />
{<br />
	a21 = -1*cos((t*pi)/180);<br />
	return a21;<br />
}<br />
<br />
double h(double t)<br />
{<br />
	a22 = sin((t*pi)/180);<br />
	return a22;<br />
}<br />
<br />
<br />
void printarray (double arg[][3]) <br />
{<br />
  for (int i=0; i<rows; i++)//for each row<br />
  {<br />
	  for (int j=0; j<cols; j++)	//for each column value<br />
		  cout << arg[i][j] << " ";<br />
	  cout << "\n";<br />
  }<br />
}<br />
<br />
void printarray2(double arg[]) <br />
{<br />
  for (int i=0; i<rows; i++)//for each row<br />
  {<br />
	  //for (int j=0; j<3; j++)	//for each column value<br />
		  cout << arg[i] << " ";<br />
	  cout << "\n";<br />
  }<br />
}<br />
<br />
	//code for multiplication of the dip and azim matrices<br />
/*	void mult(double fr_array2 [3])<br />
	{<br />
		for(int i=0;i<rows;i++)	//for each row<br />
		{<br />
			for(int j=0;j<cols;j++)	//for each column<br />
			{<br />
				for(int k=0;k<cols;k++)	//for each column<br />
				{<br />
					for(int l=0;l<cols;l++)	//for each column<br />
					{<br />
					//	fr_array [i][j] += dip_array [i][k]*azim_array [k][j];<br />
						fr_array [i][j] += lambda_array [i][l]*dip_array [l][k]*azim_array[k][j];<br />
						fr_array2 [i] += fr_array[i][j]*r_array[i];<br />
					}<br />
				}<br />
			}<br />
		}<br />
	}*/<br />
<br />
<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
	<br />
	cout<<"ANISOTROPY MODELLING.\n";<br />
	cout<<"\nPlease enter a real number between 0 and 360 for the azimuth angle, theta, then press the 'Enter' key.\n\n";<br />
	cin>>t;<br />
<br />
	cout<<"\nPlease enter a real number between 0 and 360 for the dip angle, phi, then press the 'Enter' key.\n\n";<br />
	cin>>p;<br />
<br />
	a(p);<br />
	b(p);<br />
	c(p);<br />
	d(p);<br />
	e(t);<br />
	f(t);<br />
	g(t);<br />
	h(t);<br />
<br />
	//-----------------------------------------------------------<br />
	//Initializing the matrices<br />
	//-----------------------------------------------------------<br />
	//array that holds the dip angle, phi<br />
	double dip_array [3][3] = {{d11,0,d13},{0,1,0},{d31,0,d33}};	<br />
<br />
	//array that holds the azimuth angle, theta<br />
	double azim_array [3][3] = {{a11,a12,0},{a21,a22,0},{0,0,1}};	<br />
<br />
	//array that holds the anisotropy ratios<br />
	double lambda_array [3][3] = {{lambda1,0,0},{0,1,0},{0,0,lambda2}};	<br />
<br />
	//array that holds the original range values<br />
	double r_array [3] = {4,8,3.94};<br />
<br />
<br />
	//----------------------------------------------------------------<br />
<br />
	//code to check that the arrays are properly initialized in the matrices for any theta,phi<br />
	cout<<"\nThe dip array is:\n";<br />
	printarray(dip_array);<br />
<br />
	cout<<"\nThe azimuth array is:\n";<br />
	printarray(azim_array);<br />
<br />
	cout<<"\nThe anisotropy array is:\n";<br />
	printarray(lambda_array);<br />
<br />
	cout<<"\nThe original range array is:\n";<br />
	printarray2(r_array);<br />
<br />
	//----------------------------------------------------------------<br />
<br />
	mult(fr_array2);<br />
	cout<<"\nThe final range array is:\n";<br />
	printarray2(fr_array2);<br />
<br />
<br />
<br />
	return 0;<br />
}<br />
<br />
	//code for multiplication of the matrices<br />
	void mult(double *fr_array2)<br />
	{<br />
		for(int j=0;j<cols;j++)	//for each column<br />
		{<br />
			for(int i=0;i<rows;i++)	//for each row<br />
			{<br />
				fr_array2 [j] += r_array[i]*azim_array[i][j];<br />
			}<br />
		}<br />
	}


For whatever value of theta or phi I enter, the final range array consistently reads '0' which shouldn't be. What am I missing???
GeneralLSB Insertion Algorithm Pin
VPNampoothiri28-Apr-05 20:50
VPNampoothiri28-Apr-05 20:50 
GeneralRe: LSB Insertion Algorithm Pin
Alexander M.,29-Apr-05 9:07
Alexander M.,29-Apr-05 9:07 
QuestionHow to Convert BITMAP image to IplImage Format Pin
hprasain28-Apr-05 20:12
hprasain28-Apr-05 20:12 
Generalcontrolling web cam Pin
Randil28-Apr-05 20:12
Randil28-Apr-05 20:12 
GeneralRe: controlling web cam Pin
ThatsAlok28-Apr-05 20:23
ThatsAlok28-Apr-05 20:23 
GeneralThreads Pin
pr_mk28-Apr-05 20:08
pr_mk28-Apr-05 20:08 
GeneralRe: Threads Pin
Ryan Binns28-Apr-05 20:48
Ryan Binns28-Apr-05 20:48 
GeneralUsing DMA to transfer data between two memory locations Pin
Vitaly Kashkarov28-Apr-05 20:07
Vitaly Kashkarov28-Apr-05 20:07 
GeneralRe: Using DMA to transfer data between two memory locations Pin
Alexander M.,29-Apr-05 9:13
Alexander M.,29-Apr-05 9:13 
QuestionHow to convert... Pin
mpallavi28-Apr-05 19:30
mpallavi28-Apr-05 19:30 
AnswerRe: How to convert... Pin
Alexander M.,29-Apr-05 9:14
Alexander M.,29-Apr-05 9:14 
QuestionHow to find open status of a file Pin
ashtwin28-Apr-05 18:40
ashtwin28-Apr-05 18:40 
QuestionHow to find launching process Pin
dmanjake28-Apr-05 18:02
dmanjake28-Apr-05 18:02 
AnswerRe: How to find launching process Pin
ThatsAlok28-Apr-05 20:23
ThatsAlok28-Apr-05 20:23 
GeneralRe: How to find launching process Pin
dmanjake29-Apr-05 4:37
dmanjake29-Apr-05 4:37 
GeneralRe: How to find launching process Pin
ThatsAlok29-Apr-05 19:58
ThatsAlok29-Apr-05 19:58 
GeneralRe: How to find launching process Pin
dmanjake30-Apr-05 3:47
dmanjake30-Apr-05 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.