Tuesday, July 14, 2009

In linux which function will do the work of flushall() function in C?

flushall() function is ued to clear the buffer in ansi C.


in linux flushall() is showing error.(undefined reference )

In linux which function will do the work of flushall() function in C?
flushall is not ANSI C.





For linux, maybe fpurge and __fpurge are what you are looking for?
Reply:Good places to post LINUX questions:
Reply:C is a programming language


Linux is a operating system





you won't have the same function.... :s





there's no output buffer to flush in a operating system.

sundew

How can I optimize a C++.NET DLL?

I've just finished creating a .NET Class Library DLL of a C++ Application I've been working on.





It mainly deals with graphics processing routines and the purpose of the DLL is so that I can use it with my primary application which is written in C#.





I've successfully added the DLL as a reference and I can call the functions but some of the routines that take 1 second to complete when run in standard C++ take nearly 50 seconds to complete when called from C# across the DLL.





I wrote a quick function to return a Bitmap loaded from file across the DLL and C# was able to get *this* done in a second, so I'm assuming it's my Bitmap filter routines that need optimizing.





Does anyone have some helpful tips on how I can re-do the DLL without major routines re-writes or optimize it so that the processing times are about the same as they conventionally are?





Thanks!

How can I optimize a C++.NET DLL?
So that i understand this correctly, you wrote a DLL in C++ and are referencing it from C#...Makes sense....And you mention that that DLL, when it takes action, normally thakes 1 second to process a loaded bitmap (using your filter routine) but when you call that same C++ function(s) from your C# app then the result takes 50+ secs?





And you've narrowed it down to not be the problem of the Bitmap loading (either from C++ or C#) but potentially the Bitmap filtering routines held in the C++ DLL when being requested from C#?





Not sure if you would want to do this but have you tried inlining the C++ unmanaged code routines within your C# app and see if that helps (C# can execute C++ code too -- in unmanaged mode, of course).





It is a bit strange to me why your routines take 50+ seconds when being requested from C# because i've done some very intense graphical stuff in the same manner (C# to C++ dll) and have not experienced this before. Granted the DLL and its dependent libraries are not loaded at runtime until required by the C# code and so when you make your requests it is technically then starting to put your code into memory and process it (and its supporting libraries) -- this is possibly the slow down...You could have it loaded immediately into your process space when your c# code launches


I am looking for a rare book entitled something like, 100,000 Years B. C. Giordano Bruno may be referenced.?

It would be a book on Philosophy or Spirituality.

I am looking for a rare book entitled something like, 100,000 Years B. C. Giordano Bruno may be referenced.?
Have you tried on Ebay or Amazon.com ?
Reply:Check bigjar.com in Phila Pa. Phila is full of used and rare book stores.


V=u+at which means ds/dt=u+at. Then integrate both sides and s=ut+0.5at^2+c where c is a constant but why is c

v=u+at which means ds/dt=u+at. Then integrate both sides and s=ut+0.5at^2+c where c is a constant but why is c always left out when we have a reference point?





Side question also related to projectile motion:


How does air resistance affect the range of the motion?


How does the angle change ,compared to the angle without air resistance to reach a point, when there is air resistance to reach the similiar point?

V=u+at which means ds/dt=u+at. Then integrate both sides and s=ut+0.5at^2+c where c is a constant but why is c
There are infinitely many curves that satisfy the differential equation s' = u + at. We need information, to uniquely identify the required curve.


Given a reference point is an initial condition.





Your side question i am not sure of because its been a long time since i did physics,
Reply:The constant c is left out because the reference point constraint defines the constant. Note that if you did not define u, you would have TWO constant terms for the displacement eqtn, c1*t and c2.





Air resistance slows the projectile, and the total range will be lower than in a vacuum.





The shape of the path of the projectile in a vacuum is a parabola. So if it is projected upwards at an angle theta and the target is at the same level, the projectile will hit at the angle theta.


For a projectile in air, the angle at which the projectile hits the target is greater than theta.
Reply:s=ut+0.5at^2+c





This is a general solution.





You have to find the value of C from the initial condition.





That is valid for any integration.





Now when t = 0 we know S = 0.If you wish you can take it to be some value C.





If we take S = 0 when t = 0, then putting these values in the equation





s=ut+0.5at^2+c , we get C = 0.





Thus in all equations we assume that at the start the distance is zero.





If it starts from some distance c in the beginning, then the equation is





s=ut+0.5at^2+c or





[s-c] = ut+0.5at^2.


--------------------------------------...





In projectile motion, if there is resistance due to air, then both the horizontal and vertical motion are affected by the resistance.





If ma is the force of friction, then a is the acceleration opposing the motion.





Then the verrticl motion we use [g-a] instead of g alone.


The vertical acceleration decreases.





and in horizontal motion the equations to be used are





v = u –at . s = ut -1/2at^2 , v^2 –u^2 = -2as etc and solve accordingly





t=The angle is always determined by the ratio of the horizontal and vertical velocities at that instant
Reply:Because c represents the initial position(initial value of s) and at a reference point you´´ll take it normally =0


The influence of air resistance is very complicated and the differential equation is completely different
Reply:♥ sorry I’m late with my answer; let me also put in a few words.


♠ constant c in


s=ut+0.5at^2+c solution


of differential eqn s’=u+at


is always taken into account!


Its value depends on initial condition attached to differential equation.


☺If initial condition says “at t=0 s(0)=0” then


s(0)=u*0+0.5a*0^2+c, hence c=0; thus your final solution looks


s(t)=ut+0.5at^2+0, that is s(t)=ut+0.5at^2;


☻Suppose initial condition says “at t=0 s(0)=7.7”; Then


s(0)=u*0+0.5a*0^2+c, or 7.7=u*0+0.5a*0^2+c,


hence c=7.7; thus your final solution looks


s(t)=ut+0.5at^2+7.7; c is present!


♦♦ your Side Question is a real headache in artillery schools coz drag force of air and wind has a great effect on hitting a target successfully;


E.g.: differential equation with constant drag force in still air looks:


y’’ +ky’ +g=0, x’’+kx’=0, where x=x(t) and y=y(t) are describing trajectory coordinates of projectile with initial conditions x’(0)=u, x(0)=0, y’(0)=v, y(0)=0, while k should be found experimentally;


♥ the solution of this eqn looks:


x=u*f(t), y=(v +9.8/k)f(t) –9.8t/k, where f(t)=(1-exp(-kt))/k;


now if k → 0 (drag force is negligible - vacuum!),


then x=u*t and y=vt -0.5gt^2 represent recognizable parabolic trajectory!


♥ conclusion: 1)the trajectory in air is lower than that in vacuum; 2)the projectile will hit the ground sooner than in vacuum;


since tan(θ) =u/v, and muzzle speed w=√(u^2 +v^2) is constant for the given cannon, then 3) launch angle θ must be greater in air than that in vacuum.
Reply:Usually c is left out because it is always assumed that s = 0 for t = 0.





For general conditions the C constant cannot be forgotten. Its definite value will depend on the initial conditions.





Side question: Air resistance. The air friction force obeys to the following approximate law:





f = k* v^2 (1 + alpha*v^4)





(assuming the body is not too small, u is not too small and u not of the order of the sound speed).





For a free fall you can integrate the equations (hyperbolic funtions, you can find also that there is a limit speed), but for a general balistic motion the only way to find the trajectory is by computer simulation. It is very easy, Quick Basic or Borland Pascal are enough, not forgetting to use double precision arithmetic.





Then you can find that the angle to reach the maximun distance is less than 45 degrees. For u = 200 m/sec and K=0.001 (alpha= 0) the angle found is 36.7 º and the max high = 128.6 m, with the projectile falling at a distance = 1274 m. Time on air is 16.5 secs. Without air resistance the figures are: 3911 m distance, max high 347 m, time on air 24 secs.





I apologize for my poor English.





Note: Were you interested on the subjetc, I could send you the source BASIC code. Comments are in Spanish, but the instructions can be easily understood.





Hello again! at home now. From the link





http://pedroweb.dyndns.org/ashow





you can download the projectile motion simulation code (QuickBasic45) and the executable module (DOS environment). I translated the prompts into English. Resulting figures are written in an ouptut file so you can plot the trajectory with Excel or any other tool.
Reply:yes you are right.but i willrewrite the whole enunciation and solution:


suppose a particle starts(at t=0) ftrm positon s(0)and initial velocity u


and moves with uniform acceleration (constant) a along a straight line. Find the expressions for the velocity v or v(t)%26amp;position sor s(t) at time t


Solution


dv/dt=a


integrate with respect to t


v=at+B


to find the constant B, we use the initial condition v=u at t-0


u=0+B


substitute B=u above, we get expression for v(t)OR v


v=u+at


OR ds/dt=u+at


integrate with respect to t again;


s=ut+1/2at^2 +C


to find the constant C, we again use the initial condition: when t=0, s=s(0).


s(0)=C


Putting C=s(0), we get the expression for s(t) abbreviated to s


s=ut+1/2at^2+s(0).


so yor c=s(0) given by the initial condition.


sometimes we take the starting point as origin, then s(0)=0


and then the equation reduces to s=ut +1/2at^2


C++ question?

Please tell me in C++ how does return *this; relates to returning a reference in assignment operator overloading





I am confused because this is a pointer to the current object and the return value of the function is ClassName %26amp; which is a reference. so how can ClassName%26amp; be the return type when we are returning using return *this; statement.





sample code:





MyClass%26amp; MyClass::operator=(const MyClass %26amp;rhs) {


... // Do the assignment operation!





return *this; // Return a reference to myself.


}

C++ question?
well a reference is like a pointer whose address you can't set so *this returns a MyClass Object and c++ can automatically make a MyClass reference from an objec.t

baby breath

If I'm writing a VB.NET command line app, how do I reference the command line parameters?

for example, if I type:





C:%26gt; myapp.exe -s -t





how do I reference the command line parameters ("-s" and "-t") so I can use them in my application?

If I'm writing a VB.NET command line app, how do I reference the command line parameters?
Re-declare Main like this:





static void Main(string[] args)





(that's C# syntax btw)


Pointer to reference conversion?

in c++ how do I convert a pointer to a reference without using rtti depedency, I know its dangerous but the conversion is only made after a null pointer check has been made

yucca