CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Feb 2004
    Location
    I am a Malaysian
    Posts
    14

    One question, but wew I hope I can get many answers

    Howdy ???

    Very short and very easy question !!!! (easy to you, my Gurus)

    Do you know how to decide whether 2 rational polynomials with n variables are equal ?
    Thanks,

    You Gurus , the great !!!

  2. #2
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720
    What is meant 'with n variables'? Do you mean polynomial of n-th power, or...
    Code:
    P(x0,...,xn-1) = Sum(0, n-1)(Sum(0,n-1)(a[i][j]*x[i]^j))
    or 
    P(x)=Sum(0,n-1)(a[i]*x^i)
    Anyways, you should check its coefficents.

  3. #3
    Join Date
    Feb 2004
    Location
    I am a Malaysian
    Posts
    14
    Thanks,
    and my next question is "how about Monte Carlo variety ?" I mean a kind of randomized algorithm.

  4. #4
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863
    You need to specify what you are talking about.

    Is a rational polynomial, a polynomial with rational coefficients
    or are you talking about a rational function, a ratio of polynomials.
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

  5. #5
    Join Date
    Feb 2004
    Location
    I am a Malaysian
    Posts
    14
    Originally posted by souldog
    You need to specify what you are talking about.

    Is a rational polynomial, a polynomial with rational coefficients
    or are you talking about a rational function, a ratio of polynomials.
    Oh well, all of them,
    So, can you tell me all of such situations, I love to hear from you really very much.
    Please tell me what I should do in each situation ??

    Thanks

  6. #6
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    762
    I don't even think they realized that you're trying to sneakily get them to do your homework.

  7. #7
    Join Date
    Feb 2004
    Location
    I am a Malaysian
    Posts
    14
    Originally posted by kasracer
    I don't even think they realized that you're trying to sneakily get them to do your homework.
    Thanks,
    but can you give me a hint to [underlined]my homework[/underlined] ??????

    Thanks

  8. #8
    Join Date
    Feb 2004
    Location
    I am a Malaysian
    Posts
    14
    I mean yes. that is homework but can you give me some solutions to that trivial homework ??

    kasracer, I don't know who you are on this board but I read some of your posts posted by username<kasracer> and I find that you 've never given ANY specific solutions to ANY problems, I don't understand why you can keep your face straight like that ???????

    Now can you tell me how to solve this problem ?????

    I need to an algorithm to solve it in linear time O(n) or O(nlogn), can you give me one ???

    Thanks,

  9. #9
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720
    Code:
    #include <vector>
    
    template <typename T>
    class poly
    {
    	std::vector<T> coeff;
    public:
    	inline explicit poly(const size_t &n=5) : coeff(std::vector<T>(n)) {}
    	inline explicit poly(const std::vector &vec) : coeff(coeff) {}
    	inline explicit poly(const poly<T> &another) : coeff(another.coeff) {}
    	inline explicit poly(const T *pArr, const size_t &n) : coeff(std::vector<T>(pArr, pArr+n)) {}
    
    	inline bool operator==(const poly<T> &another)
    	{
    		return another.coeff==coeff;
    	}
    	inline bool operator!=(const poly<T> &another)
    	{
    		return another.coeff!=coeff;
    	}
    	bool evaluate(T arg, T &ret)
    	{
    		size_t n=coeff.size();
    		if(!n) return false;
    		ret=coeff[0];
    		for(size_t i=1;i<n;++i)
    		{
    			ret+=arg*coeff[i];
    			arg*=arg;
    		}
    		return true;
    	}
    	inline T &operator[](const size_t &i)
    	{
    		return coeff[i];
    	}
    };
    int main()
    {
    	int coeff1[]={1,4,7,4,7};
    	int coeff2[]={1,4,7,4,7};
    
    	poly<int> p1(coeff1, 5), p2(coeff2, 5);
    	int s;
    	p1.evaluate(1, s);
    	if(p1==p2)
    	{
    		//stuff
    	}
    	return 0;
    }
    have fun

  10. #10
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    762
    Originally posted by AppleGold
    I mean yes. that is homework but can you give me some solutions to that trivial homework ??
    We don't just give solutions to homework problems (you got lucky with AvDev). If you atleast try it, we'll help.
    Originally posted by AppleGold
    kasracer, I don't know who you are on this board but I read some of your posts posted by username<kasracer> and I find that you 've never given ANY specific solutions to ANY problems
    Wow, you must really suck at searching. I try to help all the time and one of my last posts in the other C++ forum was a specific solution.
    Originally posted by AppleGold
    I don't understand why you can keep your face straight like that ???????
    Yes my "face" is "straight".

  11. #11
    Join Date
    Feb 2004
    Location
    I am a Malaysian
    Posts
    14
    Thanks Avdav,


    edit: Kasracer!!! What were you talking about ? I mean what you meant by one of your last posts in other C++ forum ? What forum ? Tell me, I like to have a look at it .
    Last edited by AppleGold; February 28th, 2004 at 07:16 PM.

  12. #12
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    762
    Originally posted by AppleGold
    Kasracer!!! What were you talking about ? I mean what you meant by one of your last posts in other C++ forum ? What forum ? Tell me, I like to have a look at it .
    You said you searched moron. It isn't that difficult.

  13. #13
    Join Date
    Feb 2004
    Location
    I am a Malaysian
    Posts
    14
    Originally posted by kasracer
    You said you searched moron. It isn't that difficult.
    Okay, Okay, cool man !!!
    If you want to be UP, so I say you ae UP, okay,
    didnt know the exact problem though !!!

  14. #14
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    I don't know about mathematical stuff such as this. I would appreciate it if you were to make the subject indicate what the question is about, so I don't waste time looking at questions I can't help with.

    Also, I have doubts that this question is appropriate for the C++ forum. As far as I can tell, this is not a programming question. If so, then you must expect people to tell you to get out of here.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  15. #15
    Join Date
    Feb 2004
    Location
    I am a Malaysian
    Posts
    14
    Originally posted by Sam Hobbs
    I don't know about mathematical stuff such as this. I would appreciate it if you were to make the subject indicate what the question is about, so I don't waste time looking at questions I can't help with.

    Also, I have doubts that this question is appropriate for the C++ forum. As far as I can tell, this is not a programming question. If so, then you must expect people to tell you to get out of here.
    Thank you much for your mentioning what I should do to make it clearer.
    You shouldnot doubt because I think I post at the right place,

    Thanks

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured