School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
You're Browsing As A Guest! Register Now...
Become an Expert!

Join 353,816 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,493 people online right now.Registration is fast and FREE... Join Now!



help in converting c++ code to matlab code

help in converting c++ code to matlab code Rate Topic: -----

#1 kaalie  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-November 08


Dream Kudos: 0

Posted 07 November 2008 - 08:41 AM

Hi,

Can somebody help me get the matlab code for the following c++ code.

int x = px;
	int y = py;
	
	//Setup initial variables
	//Maintain throughout that ax * px + bx * py = x and that ay * px + by * py = y
	int ax = 1;
	int ay = 0;
	int bx = 0;
	int by = 1;
	
	//Perform extended gcd
	while(x)
	{
		if(x <= y)
		{
			int m = y / x;
			y -= m * x;
			ay -= ax * m;
			by -= bx * m;
		}
		else
		{
			swap(x, y);
			swap(ax, ay);
			swap(bx, by);
		}
	}
	
	int inverse = ay % py;
	if(inverse < 0) inverse += py;__________________



Thanks
Was This Post Helpful? 0
  • +
  • -


#2 PsychoCoder  Icon User is offline

  • apt-get install DIC.bin
  • Icon

Reputation: 701
  • View blog
  • Posts: 16,787
  • Joined: 26-July 07


Dream Kudos: 12450

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Re: help in converting c++ code to matlab code

Posted 07 November 2008 - 09:01 AM

First and foremost:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.

Second, what does this have to do with C#, since that's the forum you posted this in? Third, please, when posting code, put it inside code tags, like this => :code:

Now, I'm moving this to the Other Languages forum since it don't belong in the C# forum :)
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month