Thread: Kind request for help

  1. #1
    Registered User
    Join Date
    Feb 2013

    Kind request for help

    Hello everyone. I am new on the forum, and also quite new to c++. Currently I develop some computational program, and have a problem with implementation of the formula(s). Let me explain this. I want to obtain smix:
    Kind request for help-2-png
    wherein sk:
    Kind request for help-1-png
    k = 0 - 4
    x is the 5 element vector, that has x0 - x4 elements
    d is the 11 element coefficient vector, that has d0 - d10 elements
    in the formula b is 10 element vector, whose indexing begins from 1 (this is in the document from which the above formulas come), in the program indexing begins from 0, so bi element from the formula is b[i-1] in my program.
    I could simply implement this, no big deal - unless xk would not equal 0... When xk = 0, the natural logarithm cannot be computed, so i must add some checking if xk = 0, if yes the program should skip computing ln(xk) (sk should not be taken into account in that situation as well).
    I have tried to implement for/if combination, but it seems to surpass me... So I am kindly asking you - people of good will - to help me resolve the problem. I am stuck with this for a few hours and because of that kinda frustrated. I will be very, very very grateful for help. Thanks in advance.

  2. #2
    Registered User
    Join Date
    Feb 2013
    Split problem into many small ones. For example first part of Smix:
    double a = 0;
    for(int i=0; <5; i++) {
    a += x[i] * s[i];
    and so forth. Very mechanical way. Also I think math.h has natural logarithm function.

  3. #3
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Nice, France
    Quote Originally Posted by zoom View Post
    I think math.h has natural logarithm function.
    True. But if you write C++, you might want to include cmath, rather than math.h (which is what C programmers use)
    Code - functions and small libraries I use

    It’s 2014 and I still use printf() for debugging.

    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  4. #4
    Registered User
    Join Date
    Feb 2013
    Thanks for reply, but... I am still in the same point. I bet this can be done in some more "civilized" way, i mean compact/concise. For example with a combination of for and if instructions. And of course cmath has natural logarithm function.

  5. #5
    Registered User
    Join Date
    Feb 2013
    I'd like to correct and clear some things in the description, sorry for the mess, I was a bit tired when posting. So here it is:

    k = 0 - 4 (this is just naming for the 5 different substances, because the program computes some property of these substances, and the property of its mixture)

    x is a scalar, there are 5 such a scalars (for every k), so I put them into one vector

    dk, that is d0 - d4 are the 11 element coefficient vectors

    Any idea?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. kind of new here and need help
    By yasharm in forum C Programming
    Replies: 7
    Last Post: 01-03-2007, 11:35 AM
  2. would anybody be kind enough to help?
    By almich in forum C++ Programming
    Replies: 10
    Last Post: 07-07-2004, 05:49 AM
  3. Getting three of a kind
    By Kons in forum C Programming
    Replies: 8
    Last Post: 08-19-2003, 12:44 PM
  4. What kind of car do you have?
    By Tleggo in forum A Brief History of
    Replies: 50
    Last Post: 06-13-2002, 03:56 PM
  5. anyone who is kind?
    By Christine in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2001, 02:55 PM