Science topic

C - Science topic

Explore the latest questions and answers in C, and find C experts.
Questions related to C
  • asked a question related to C
Question
17 answers
Right now, in 2022, we can read with perfect understanding mathematical articles and books
written a century ago. It is indeed remarkable how the way we do mathematics has stabilised.
The difference between the mathematics of 1922 and 2022 is small compared to that between the mathematics of 1922 and 1822.
Looking beyond classical ZFC-based mathematics, a tremendous amount of effort has been put
into formalising all areas of mathematics within the framework of program-language implementations (for instance Coq, Agda) of the univalent extension of dependent type theory (homotopy type theory).
But Coq and Agda are complex programs which depend on other programs (OCaml and Haskell) and frameworks (for instance operating systems and C libraries) to function. In the future if we have new CPU architectures then
Coq and Agda would have to be compiled again. OCaml and Haskell would have to be compiled again.
Both software and operating systems are rapidly changing and have always been so. What is here today is deprecated tomorrow.
My question is: what guarantee do we have that the huge libraries of the current formal mathematics projects in Agda, Coq or other languages will still be relevant or even "runnable" (for instance type-checkable) without having to resort to emulators and computer archaeology 10, 20, 50 or 100 years from now ?
10 years from now will Agda be backwards compatible enough to still recognise
current Agda files ?
Have there been any organised efforts to guarantee permanent backward compatibility for all future versions of Agda and Coq ? Or OCaml and Haskell ?
Perhaps the formal mathematics project should be carried out within a meta-programing language, a simpler more abstract framework (with a uniform syntax) comprehensible at once to logicians, mathematicians and programers and which can be converted automatically into the latest version of Agda or Coq ?
Relevant answer
Answer
I just encountered a notification about this article on Mathematical Proofs and the value of Proof Assistants, https://www.ams.org/journals/notices/202401/rnoti-p79.pdf
I resonate most with the positions by Lamport (author of LaTex and a Turing Award Laureate) and Laurence Paulson (author of ML for the Working Programmer and working very much in proof assistants). I think it will be clear that the situation about the presentation of proofs and incorporation of such proofs in mathematical publication is still very much up in the air.
I also did a ResearchGate search on "Proof Assistant" and the fire-hose of articles confirmed my view that this is yet stabilizing, although there are extensive favorite approaches.
Here is the above paper's abstract:
“A proof is one of the most important concepts of mathematics. However, there is a striking difference between how a proof is defined in theory and how it is used in practice. This puts the unique status of mathematics as exact science into peril. Now may be the time to reconcile theory and practice, i.e., precision and intuition, through the advent of computer proof assistants. This used to be a topic for experts in specialized communities. However, mathematical proofs have become increasingly sophisticated, stretching the boundaries of what is humanly comprehensible, so that leading mathematicians have asked for formal verification of their proofs. At the same time, major theorems in mathematics have recently been computer-verified by people from outside of these communities, even by beginning students. This article investigates the different definitions of a proof, the gap between them, and possibilities to build bridges. It is written as a polemic or a collage by different members of the communities in mathematics and computer science at different stages of their careers, challenging well-known preconceptions and exploring new perspectives.”
There is already an objection to this material on the list where I found it. The objection is to this statement: "This puts the unique status of mathematics as exact science into peril.” That statement disturbs me too, but maybe not for the same reason.
  • asked a question related to C
Question
22 answers
Animations are known to be a fast and very efficient way of dissemination of knowledge, insights, and understanding of complex systems. Through the animations, quite complicated research can be easily shared among all scientific disciplines.
While starting with complex systems descriptions of Dynamic Recrystallization in metals about almost 30 years ago, it had become very obvious almost instantly that animations carry with themselves a huge expressive power.
This recently led to development of the GoL-N24 open-source Python software that enables to create animations effortlessly. The user just defines the input parameters and the rest is done automatically. Share your software too.
This question is dedicated to all such animations and open-source-source software, which are producing them, in the area of complex systems.
Everyone is welcomed to share their own research in the form of animations with the relevant description.
Relevant answer
Answer
This animation is depicting an array of identical emergents observed withing one specific neighborhood of GoL-N24 software. This emergent is called the frog.
See details in the review:
  • asked a question related to C
Question
2 answers
the repellent activity is different than the excito-repellent (landing is differ than sucking)
when we use the repellent, we can calculate their repellent activity by using the percentage of protection P= (C-T)/C x 100
when we use excito repellent, how can we calculate the percentage of bitting.
Thank you
Relevant answer
Answer
Please describe "exito repellent" in context of Entomology
  • asked a question related to C
Question
2 answers
Hello,
I've successfully simulated the closure of a flapper non-return valve as illustrated.
The inlet velocity increases gradually with a specific acceleration.
The following UDF is used to specify the motion of the flapper:
#include "udf.h"
DEFINE_SDOF_PROPERTIES(flappers_motion, sdof_prop, dt, time, dtime)
{
Six_DOF_Object *sdof_obj = NULL;
sdof_prop[SDOF_MASS] = 2.73e-3; /* flapper's submerged weight */
sdof_prop[SDOF_IXX] = 2161.86e-9; /* around the hinge */
sdof_prop[SDOF_IYY] = 367.96e-9;
sdof_prop[SDOF_IZZ] = 2471.27e-9;
real m= sdof_prop[SDOF_MASS];
real L= 0.024479 ;
sdof_prop[SDOF_LOAD_M_X] = 0 ;
sdof_prop[SDOF_LOAD_M_Y] = 0.0;
sdof_prop[SDOF_LOAD_M_Z] = 0.0;
real th_deg = theta * 180 * 7 / 22 ; /* valve opening angle, in degree */
sdof_obj = Get_SDOF_Object(DT_PU_NAME(dt));
if (NULLP(sdof_obj))
{
/* Allocate_SDOF_Object must be called with the same name as the udf */
sdof_obj = Allocate_SDOF_Object(DT_PU_NAME(dt));
SDOFO_1DOF_R_P(sdof_obj) = TRUE; /*1DOF rotation*/
SDOFO_DIR(sdof_obj)[0] = 1.0;
SDOFO_DIR(sdof_obj)[1] = 0.0;
SDOFO_DIR(sdof_obj)[2] = 0.0;
SDOFO_CENTER_ROT(sdof_obj)[0] = 0.0;
SDOFO_CENTER_ROT(sdof_obj)[1] = 0.0;
SDOFO_CENTER_ROT(sdof_obj)[2] = 0.0;
SDOFO_CONS_P(sdof_obj) = TRUE; /* constrained motion */
if (SDOFO_CONS_P(sdof_obj))
{
SDOFO_LOC(sdof_obj) = 0.0;
SDOFO_MIN(sdof_obj) = -0.0349 ; /* min allowable angle */
SDOFO_MAX(sdof_obj) = 1.0471 ; /* max allowable angle */
SDOFO_INIT(sdof_obj) = SDOFO_LOC(sdof_obj);
SDOFO_LOC_N(sdof_obj) = SDOFO_LOC(sdof_obj);
}
}
}
But now I want to simulate the closure of the flapper, taking into account the friction at the flapper's hinge.
I tried to just assign the friction value to "sdof_prop[SDOF_LOAD_M_X]" ,but the flapper started to move backwards (opening) until the flow increases, which is not correct.
So I want to get the value of the hydrodynamic torque of the flapper, and compare it to the friction with some kind of "if statement" that may look like this:
real static_friction= 50;
real kinetic_friction=40;
real hydraulic_torque =??? ;
If (hydraulic_torque<static_friction)
{
sdof_prop[SDOF_LOAD_M_X]=0
}
else
{
sdof_prop[SDOF_LOAD_M_X]=-1*kinetic_friction;
}
BUT THE PROBLEM IS :
I don't know the udf code that can get the actual value of the hydraulic_torque on the flapper to compare it to the friction value.
Your help is highly appreciated.
Thanks a lot in advance.
Relevant answer
Answer
Ok, I've found how,
In case of someone else has the same issue,
Use the macro :
Compute_force_and_moment
Within the 6dof code
  • asked a question related to C
Question
3 answers
Hello experts,
I hope you're good.
I am trying to generate non binary (optimized) lfrs sequence on the fly with c.
But I am missing something, I don't get what ...
attached is the code ....
Relevant answer
Answer
  • asked a question related to C
Question
5 answers
can anyone suggest the best way to find the accurate execution time of math.h library functions such as sqrt(), log(), log10(), sin(), cos() e.t.c?
Relevant answer
Answer
Although this qs is little old, I have some answer to contribute:
Here's a code snippet (time.h and math.h need to be #included):
clock_t start = clock();
double x = sqrt(125.0); // or any other function
clock_t finish = clock();
double exec_time = (double)(finish - start) / CLOCKS_PER_SEC;
If you are using the Unix variant, then from command prompt within the shell, we may run as:
$ time ./myexec
where myexec is the name of the executable file.
Unix time command prints time spent by the executable as real-time, user mode CPU time and system mode CPU time.
  • asked a question related to C
Question
24 answers
If so, why should we neglect the effect of gravitational potential from remote masses of the universe which is about 106 times larger than the additional gravitational potential at the Sun's surface ??
Relevant answer
Answer
GR theory predicts that a distant observer looking at a region that has a somewhat increased gravitational potential U will see that clocks are slowed in the region, and that the speed of light there is reduced. Both of these effects are proportional to the U value. (The U value for a spherical mass is Gm/(c^2 r), a positive value.). The effects are NOT proportional to the gradient of the potential, which decreases with r^2. Gravitational ACCELERATIONS towards a mass are proportional to the mass’s gravitational potential gradient, but the gradient doesn’t cause the slowing effects.
The clock-slowing effect is indisputable, as atomic clocks on the Earth can be used to accurately measure even small elevation differences. Observing the reduction in the speed of light is more difficult than observing clock-slowing, but in the 1970’s NASA’s Viking experiment carefully measured the pattern of the delay of radio waves sent on a round trip to Mars. The waves’ path was initially far from the sun, but over several months Mars’s orbit brought the path closer and closer to the sun and the time delay increased. The observed pattern of delay times matched the GR prediction: the slowing during each round trip was proportional to the solar gravitational potential, and not proportional to its gradient.
GR also correctly predicts the amount of refraction of light waves passing near to the sun. The curvature of the light path is proportional to the gradient of the sun’s potential.
Johan K. Fremerey states correctly that the gravitational potential of distant masses, felt here within the solar system, is far greater than the potential due to the solar system’s masses, even though the gradient of the distant masses' potential is negligible. Our observed slowing of light passing near to the sun reflects the DIFFERENCE between the potential at the Earth and the potential at the sun.
A hypothetical observer in deep space would perceive that compared to its deep-space speed the speed of light in and around the solar system was significantly reduced, due to the gravitational potential of the Milky Way and our Local Group of galaxies. That observer would see the speed was slowed slightly more near to the Earth, and slightly more again near to the sun. In the Viking experiment we just saw the difference between those two factors.
A comment: I think that GR theory is invalid. However, it gets the right answers for low-intensity gravitational fields. The consistency of those answers gives me confidence that the astronomers’ analyses of gravitational lensing effects are valid, and that the calculated patterns of dark matter in and around galaxies are correct.
  • asked a question related to C
Question
7 answers
How could we profile a c program in order to obtain detailed information related to its executed instructions (Dynamic Instructions)? I'm looking for a tool with which I can use it to obtain information per dynamic instruction, for example
The 1st Instruction is executed 10 times
The 2nd Instruction is executed 5 times
The 3rd Instruction is executed 7 times and so on.
Moreover, taking into account arithmetic instructions, is it possible to determine the results that those instructions produce for each time they are being executed (the partial results produced by a dynamic instruction at an arbitrary clock cycle)?
By doing so, we can state that instruction 1 is going to execute 10 times and the results it produces are the same as across these 10 times. Therefore, we can ignore 9 dynamic instructions of instruction 1, and only consider one instance.
I Still haven't found what I'm looking for!
Relevant answer
Answer
Ms Visual studio code is good for these things.
  • asked a question related to C
Question
3 answers
Hello everyone, I’m wondering if anyone can help me in using the finite element analysis code “FEMIX.4”. As i want to simulate the non-linear behaviour of concrete utilizing 3D multi directional fixed smeared crack model using FEMIX. And i’m not very familiar with such computer codes.
thanks in advance.
Relevant answer
Answer
pleasure Mohamed Sherif
Stay Happy Stay Healthy.
  • asked a question related to C
Question
6 answers
Hello everyone,
I'm trying to model the motion of a cylinder in both CF and IL directions, but the UDF code that I have only can move the cylinder in the CF direction. Sadly I have never had the chance to learn to code UDF. Can someone please help me?
I will share the code below.
I really appreciate any help you can provide or at least promote this question to find the best answer to my issue.
FYI, this code is for Vortex-Induced Vibration of cylinders
####################################################
#include "udf.h"
#include "dynamesh_tools.h"
#include "unsteady.h"
FILE *fout;
static real v_prev;
DEFINE_SDOF_PROPERTIES(stage,prop,dt,time,dtime)
{
Thread *t;
Domain *d=Get_Domain(1);
real x_cg[3],force[2],moment[3];
real cg; /*Center of gravity position*/
real vel; /*Cylinder velocity*/
real Fy; /*Lift Force*/
real mass=8.88; /*Cylinder mass*/
real fn=1.06; /*System frequancy*/
real wn=2*M_PI*fn; /*System angular velocity*/
real z=0.002; /*Damping coefficeint*/
real k=mass*wn*wn; /*System stiffness*/
real c=2*mass*wn*z; /*System damping*/
/*Get the thread pointer for this which motion is define*/
t=DT_THREAD(dt);
prop[SDOF_MASS]=8.88; /*System mass of the 6DFOF*/
prop[SDOF_ZERO_TRANS_X]=TRUE;
prop[SDOF_ZERO_TRANS_Z]=TRUE;
prop[SDOF_ZERO_ROT_X]=TRUE;
prop[SDOF_ZERO_ROT_Y]=TRUE;
prop[SDOF_ZERO_ROT_Z]=TRUE;
cg=DT_CG(dt)[1];
vel=DT_VEL_CG(dt)[1];
prop[SDOF_LOAD_F_Y]=-k*cg-vel*c;
fout=fopen("results.txt", "a"); /*Open file*/
/*Wrtie data into file*/
fprintf(fout, "%g %g %g\n",time,DT_CG(dt)[1],DT_VEL_CG(dt)[1]);
fclose(fout);
}
Relevant answer
  • asked a question related to C
Question
2 answers
Hello;
I am currently working on a UDFusing the DEFINE_HET_RXN_RATE for Heterogeneous reactions. My idea is to use VOF to describe a simple method of VLE using the vapor pressure of condensable components (in my case water and methanol). I am using the Evaporation-Condensation UDF provided by Ansys in their manual UDF book as a baseline.
By now, I am having trouble with filtering the rate of the reaction based on their names. I was trying to use STREQ and !strcmp command, but every time I compile it gave me the following message:
  • error: member reference base type 'real' (aka 'double') is not a structure or union
Besides a problem with an exponent where its values depend on the temperature, it is the only problem I have so I can test the UDF.
  • asked a question related to C
Question
3 answers
I want to understand C5.0 algorithm for data classification , is there any one have the steps for it or the original paper that this is algorithm was presented in ?
Relevant answer
  • asked a question related to C
Question
3 answers
I'm working on the simulation of thermal behavior of Ionanofluids, which is an ionic liquid-based-fluid in which nanoparticles were suspended to enhance the thermal performance. Multiple researches in the matter are taking in consideration more physical propreties to help predict these newly introduced fluids' thermal performance. Despite the rarety of experimental studies, they are credible and have very convincing models based on experimental observations and interpretations. In most cases a model for the thermal conductivity or for heat capacity was introduced to help predict the thermal performance. So in order for me to carry on a sophisticated numerical study i'm trying to introduce these models into Ansys Fluent as UDFs in order to compare or confirm with the experimental studies. This will enable me also, throw parametric studies to try multiple combinations of the ionic liquids+nanoparticles and compare their performance and cost effectiveness.
Thank you so much for your help and any advice in the matter will be helpful also.
Relevant answer
Answer
Yeah because it has been proved previously, that there is an interaction between the nanoparticles and the ionic liquid that results an interfacial layer increasing the thermal conductivity. Thank you so much.
  • asked a question related to C
Question
8 answers
Could you please explain the differentiation of aninal to meat with percentage wise distribution.
Carcass yield, bone %(live wt, carcass wt), meat%
  • asked a question related to C
Question
4 answers
I have Pandas DataFrame and Numpy.ndArray
I want to select DataFrame elements based on values contained in Numpy.ndArray
Eg:
L is Numpy.ndArray values
`L=array([2,2,2,1,1,1])`
P is Pandas dataFrame which has many columns of type Numpy.ndArray
P's 1st columns is
`array(['A','B','C','D','E','F'])`
Result expected
two different columns
`['A','B','C']` which is corresponding to 2 value
`['D','E','F']` which is corresponding to 1 value
Relevant answer
Answer
This article for row and column selection from pandas dataframe can be useful
  • asked a question related to C
Question
3 answers
Hi there. Im writing a program in C to solve the viscous burgers equation in 1D using the finite volume method. I am currently using a structured uniform cartesian grid as my computational grid. However i want to implement adaptive mesh refinement in my program. Could anyone tell me the steps i should take in order to do this. Would i have to make i have to make an additional function like say Adapt_Mesh() as well as my Init_Mesh() function and call the Adapt_Mesh() function in the main time loop every time the mesh needs refinement and how could i go about determining if my mesh needs refinement or how would i go about this. Im relatively new to the realm of CFD hence im struggling a lot by thinking how to go implementing this. Could anyone help me. Id be willing to share my current code if anyone could point me in the right direction in regards with how to get started.
*EDIT: Also i have a current gird with 100 cells. If was to adapt the mesh would it refine the mesh so that NX is always 100 ie. by making areas of less density and areas of higher density so that the total points add up to 100 or does the adaptive mesh increase the number of total cells everytime the mesh is refined. This is something im unsure of.
If anyone is curiosus i have attached my program below just incase anyone wanted to take a look
Relevant answer
Answer
If you want to increase your definition step by step, you can add a parameter to your array or similar data structure:
-step 1 a[i,j], that's your current description with large cells
-step 2 a[i,j,k,l], that's the higher resolution with smaller cells in each of the previous large cells
within the neighborhood of each (i,j), you introduce further divisions (smaller cells: parameter k horizontally and l vertically)
etc...
In this way you can always go back to less definition.
Does it help you?
  • asked a question related to C
Question
5 answers
I have already tried alternatives with meat and gave us marvelous results as the meat stayed intact for 15 days at 4 C.
Relevant answer
Answer
Many herbs have proven their high pharmacological efficacy. In addition, many of the medicines are of herbal origin
beg greeting
  • asked a question related to C
Question
6 answers
I want to know more about their papers through the program, can someone write them in C or JAVA or Python?
Relevant answer
  • asked a question related to C
Question
7 answers
A colleague just does not understand how come I can be sure about c-global retrieved (which is traditionally thought to have been disproved in 1907).
My best pertinent paper (http://www.ptep-online.com/2015/PP-43-09.PDF) does not convince him.
Who has any advice to offer?
March 21, 2020
Relevant answer
Dear Otto,
Hope you are well and in good health.
If you are very convinced and firmly believe in your instruct then you can convince the other because you will find a simple method to enter his mind.
On the other side if one closes his mind and heart to your instructs he will never believe in it. Such persons you need not to convince them because you will loose you time.
The last thing is that every construct may be right or false.
Remain safe!
Best wishes
Abdelhalim Zekry
  • asked a question related to C
Question
3 answers
Example : Variable B & C together form A. To measure B we have reflective scale but C can be measured only with formative scale. 
Please provide any reference, if you have
For the model refer to the attachment 
Relevant answer
Answer
Hi, could you please let me know how have you done the calculations for this model? is it possible to use the "repeated indicators approach" for it? Thanks in advance.
  • asked a question related to C
Question
7 answers
If table is like can we draw venn diagram by this input?
variable          value r1               value r2
a                        20                         45
b                         10
c                          39                        1
d                                                      37
e                            98                     27
Relevant answer
Answer
you can use this online tool DiVenn which will generate a nice graph https://divenn.noble.org
  • asked a question related to C
Question
12 answers
Hello everyone,
which ways could I use for obtaining data about colour of every pixel in image which has .jpg or .png formats? In the end I want to get .txt file with numerical values of colours in the RGB palette to download it to FPGA by UART. If you know better methods to do this, I will be glad to learn them.
Thank you in advance.
Relevant answer
Answer
If you are using VHDL then you need to transform the image into text file and then binary. please, if you are using Verilog then use the package textio package. You might use C or matlab code to transfer the image into binary format then insert its location in the VerIilog code I attached a web site reading binary file using VHDL. However, you can also use C .
also, you need to use VHDL transmitter/ receiver file to transfer your data to FPGA. I have my own but I believe it is available as package.
in matlab
[x,map]= imread(‘location of your image ‘, ‘jpg’);
imwrite(x, ‘new file name’, ‘bmp’);
Hope it helps brother
  • asked a question related to C
Question
6 answers
Sometimes in order to gain better performance in terms of execution time, inline assembly within source code is used. For example, it is possible to write assembly code inside C code to manipulating values stored in registers. Is there a way to avoid using inline assembly inside source code? or an alternative way in this context?
Relevant answer
Answer
I don't write in C but I do write in C++, so this answer may still be relevant.
I would recommend the use of intrinsic functions, which translate directly to assembly instructions. But in the last 10 years or so optimizing compilers have gotten good enough that this is almost never needed except for very specific requirements such as requesting a prefetch of a memory location you are going to need to access a short time later.
If you need a specific algorithm sped up, I'm very good at that and might be able to help you.
  • asked a question related to C
Question
3 answers
While working on matlab to C conversion, I have encountered a problem which involves result mismatch. The function I've been trying to validate is an SVD function with its corresponding matlab built-in function. The result that is obtained from the vector of singular values (the last n by n matrix) in C implementation produces a result with column mismatch as compared to its corresponding matlab built-in function. In some of the cases the obtained result  produces opposite signed values as well.
I have attached the c implementation, I kindly ask for your cooperation in pinpointing the problem which could help me find a solution.
Relevant answer
Answer
Pion A, U;
Kw V;
Wektor S;
are not defined.
Missing additional header / source file?
  • asked a question related to C
Question
25 answers
Dear all,
This forum has been created to provide a scientific environment in Researchgate for all of those who are interested in doing research on the context of RPL in Internet of Things (IoT) networks. Through this forum, the members could discuss about their previous RPL related studies and introduce them to others, and also to share their latest discoveries, papers, and probable ideas and more importantly to provide their experience to the newly students who want to spend time on studying the existing challenges in RPL. The students who have decided to work on this topic can join this forum and ask their questions and also to get others' opinion on their current work. There exist different types of challenges for publishing a paper from getting the raw idea, and its implementation via off-the-shelf simulation tools, to submitting the final manuscript. Here in this forum, the members will try to solve these challenges as much as possible and also try to answer the questions and help each other to enhance the observability of the existing studies. Further more, members can inform others about the up coming conferences, events, and journal special issues to further provide a comfort zone for those who are attracted to this field of study.
I hope this forum will make the research on this field more interesting and easily.
Relevant answer
Answer
Dear Sadeer,
We usually use Cooja simulator as part of the Contiki operating system, which has been specifically created for resource constrained IoT plarforms, and of course, its free to use.
  • asked a question related to C
Question
2 answers
I am attempting to implement an atmospheric boundary layer in a 3D fluent simulation using a UDF. The UDF is proven to work in a 2D simulation, however approximately 10 hours into a transient 3D solution using 16 cores, fluent crashes with the only log give being a segmentation fault. I am suspicious that something is going wrong with the parallel nature of the solver, however I can't see any issues with my code - nor can I see any issues that would result in a crash 10 hours in, where the code is not time dependent.
Relevant answer
Answer
Just transient k-omega SST fluid flow
  • asked a question related to C
Question
19 answers
For somebody who already knows some programming skills and languages, what are the best and fastest strategies to master other programming languages?
Relevant answer
Answer
Apply it. Do mockup examples, try toy models, whatever floats your boat, just get your hands dirty writing code from the beginning to end. Progressively you can add complexity and structure (e.g. integrated applications, OOP) to your examples to explore the language further. Oh, and after reaching an intermediate theory, try to balance theory (books & tutorials) with examples from your domain.
  • asked a question related to C
Question
5 answers
I read that Tiny OS uses nesC language to build an application whereas Contiki OS uses C-language.
I am just starting to make a project utilizing IRIS motes and my application require multiple arithmetic operations and looping statements. I am familiar with C-language but nesC would be completely new for me (I guess) as its an extension to C-language.
So which platform will be more suitable for such application.
Relevant answer
Answer
Since you asked this question in the year 2019... IRIS Motes are too old as Tiny OS. They can support only Tiny OS Per se....
Contiki OS needs more memory (RAM and ROM), IRIS motes do not provide that,, so you have to stick to Tiny OS Itself, nesC is easier compared to Contiki OS.
  • asked a question related to C
Question
3 answers
Hi,
For compiling a C code, I am using MinGW64 compiler(c) and made following code in command line.
mex asamin.c asa.c -DUSER_ACCEPTANCE_TEST -DUSER_ASA_OUT -DDBL_MIN=2.2250738585072014e-308
The error is presented in attached picture.
Can anyone help me for understanding the problem?
Any suggestion will be very appreciated.
The Best,
Azade
Relevant answer
Answer
I can only hazard an answer: in the old days, the compilers would not check compatibility between pointer type and variable read at that memory location pointed to. That would allow nice tricks if you knew what you were doing and also nasty mistakes if you didn't. Newer compilers do not allow this anymore; i.e. when you decalre a pointer to point to say an integer variable, you cannot read from that location lets say a floatin point variable. Your error is of that kind; the problem usually arises when you use somebody elses code/libraries, as they may have been compiled in the old(er) days when the compiler would not do such checks...
  • asked a question related to C
Question
4 answers
I am looking for different questionnaires based on Bloom Taxonomy (Affective, Cognitive and Social domains) to assess the learning of computer science student in CS1 courses(such as intro to programming class with java or c or python).
Relevant answer
Answer
Can you recommend some VALID questionnaires for Affective, Cognitive and Social domain?
  • asked a question related to C
Question
7 answers
Hello,
I have a strange bug in my code involving the use of FFTW3. I already wrote the qeustion on Stackoverflow: https://stackoverflow.com/questions/53518451/why-is-fft-of-ab-different-from-ffta-fftb
Please, if anybody have some time to spare, could you have a look?
Thank you very much!
Relevant answer
Answer
Finally I solved the problem! If anybody is still interested, you can have a look on Stackoverflow, I posted an answer.
PS: Hussein Al-Rikabi Assist. Prof. Fatima Faydhe al-Azzawi I insist, the Discrete Fourier Transform is a linear operation.
  • asked a question related to C
Question
9 answers
I am a researcher of materials science and metallurgical engineering. I am interested to work with atomic level and electronic modeling of the structure and properties of materials,materials informatics and simulation in future. Currently i am learning Python. I have basics of C and MATLAB . What will be the useful programming languages to learn for me?
Relevant answer
Answer
It's hard for me to understand that C gets some recommandations whereas C++ gets ignored. Also Julia should be taken into account for structured and efficient simulations. The best thing is to get advice from within the community that you plan to join.
  • asked a question related to C
Question
3 answers
As we know, the ptrace system call is the most powerful system call in all unix-like systems. All debugging software use ptrace for monitoring and manipulating another process, i.e. tracee. Using ptrace, we can track read/write system call in the tracee process. I ask, can we use ptrace in order to monitor the tracee and notify the tracer only when the tracee executes a branch instruction? Is this possible? if not, can we notify the tracer when a specific instruction at a specific address is executed?
Advance thanks
Relevant answer
Answer
Thanks Mr. Jack Son,
Thanks Mr. Peter Breuer,
In fact, I cannot use PTRACE_SINGLESTEP, because the performance will be disastrously damaged because of transferring the control frequently from "tracee" to "tracer" and vice versa. So this idea is excluded. What I want in particular is to alert the "tracer" only and only when the "tracee" is doing a jump instructions. Maybe I can modify the code in order to rewrite a special instruction that moves control to the "tracer" (Of course, I should save the original branch instruction). The alternative instruction should arise a trap.
  • asked a question related to C
Question
4 answers
The possibility of sequencing of short primers
Relevant answer
Answer
there is no general problem using short sequencing primers ( pyrosequencing works well with them) so long as they only anneal at the right position and have no looping self complementarity and can anneal at the extension temperature of the sequencing kit but how short are you thinking. If the problem is getting as much sequence as possible from a short template then clone it and use vector primers to sequence and get the whole template sequence
  • asked a question related to C
Question
10 answers
temperature is affecting on the mechanical properties such as strength 
Relevant answer
Answer
Dear Michael Rethmeier ,
can you give more information about what do you mean
  • asked a question related to C
Question
7 answers
Hi
Please, how can we make a new operating system ?
Is the method to bring some developers with strong background in theoretical operating system operations and then they should learn from the source codes from another operating systems such as Linux various versions. Then, you can write your operating system and then testing it with ethical hackers to fix the security issues. Then, you can deploy it for some users as testing version. Then, it is validated to be used.
Please, any help for developers to do this than talking alot in useless things.
Thanks
Osman
Relevant answer
Answer
Obviously you are new to this. The first step to anything is coming up with a name. A name that can rally developers to your cause. Act fast, all the good names are taken. Without a name, you can't even market or sell or profiteer from your OS - and what good is that. ( Read Dilbert for details. )
The problem you have is pretty much it has all been done. Who wants to spend their time on re-creation rather than innovation. So you need a hook, something that is a minimally viable kernel.
So what is the thing that this new OS is to do better?
Back to Dilbert, you need a project you can market to developers as something worth working on. THAT is how you get other people to code your operating system. It also helps to have done some of the heavy lifting. That minimally viable kernel, that shows you are more than a dilettante or a provocateur.
So what is your pitch? Why do we need a new operating system, why do we need to code it for you? Go....
  • asked a question related to C
Question
3 answers
I was asked to supervise my junior in a small project about Chick hematology, because I am new to the topic I have several questions to ask :
1. My juniors are planning to see the garlic oil effect on the chick's white blood cell counts, is it possible to apply oral gavage on chick as the enteral administration method?
2. Is there any suggestion on substance that affect overall blood cell count that doesn't need oral gavage administration like syringe usage ? we are prohibited from using heavy metal
3. If you have any reference about chick hematology-related research please let me know
Thank you
Relevant answer
Answer
Dear Grace,
I think the following recent papers will help you:
Owosibo AO, Odetola OM, Odunsi OO, et al. Growth, haematology and serum biochemistry of broilers fed probiotics based diets. African Journal of Agricultural Research 2013; 8(41):5076-5081. http://www.academicjournals.org/journal/AJAR/article-full-text-pdf/3A5206141348
Akinola LAF, Etuk MO. .Haematological and Serum Biochemical Responses of Broilers Fed Varying Levels of Indomie Waste-Based Diets. IOSR Journal of Agriculture and Veterinary Science 2015;8(3):66-70. https://pdfs.semanticscholar.org/995e/f4f36bb59e9f1db0e48ae27a924a2cb8dda8.pdf
Abdulazeez H, Adamu SB, Igwebuike JU, Gwayo GJ, Muhammad AI. Haematology and Serum Biochemistry of Broiler Chickens Fed Graded Levels of Baobab (Adansonia digitata L.) Seed Meal. IOSR Journal of Agriculture and Veterinary Science 2016; 9(10):48-53. http://www.iosrjournals.org/iosr-javs/papers/Vol9-Issue10/Version-2/I0910024853.pdf
Ogunwole OA, Abu OA, Adedeji BS, et al. Haematology and Serum Indices of Finisher Broiler Chickens Fed Acidified Blood Meal-based Diets. Journal of Advances in Biology & Biotechnology 2017;11(2):1-7. https://www.researchgate.net/profile/Olugbenga_Ogunwole4/publication/312476729_Haematology_and_Serum_Indices_of_Finisher_Broiler_Chickens_Fed_Acidified_Blood_Meal-based_Diets/links/587f12e908aed3826af46bb9.pdf
Best wishes from Germany,
Martin
  • asked a question related to C
Question
4 answers
I am working on finding visualized flow graph of c program for that I want to get basic block form llvm and Clang.
Relevant answer
Answer
I have question what is the meaning of LBB in ASSEMBLY CODE generated with clnag
  • asked a question related to C
Question
6 answers
I used 27F and 1492R primers to amplify bacterial 16S rDNA from intestinal digesta, cycling conditions include 1) 94 C for 3 mins; 2) 40 cycles of 94 C for 30s, 55 C for 30s, and 72 C for 1 min; 3) 72 C for 10 mins 
After the PCR, the Nanodrop concentration of those PCR products were around 750 ng/ul. But after purification using the Invitrogen PCR purification kit, the product concentration was down to only 50 ng/ul. Is this normal?  When I used the Qubit to quantify dsDNA, the concentration became around 15 ng/ul. Was this concentration too low? 
I want to use the purified PCR product as my standard to build standard curves to quantify other bacteria (eg, Lactobacillus) concentration from gut content. 
Thanks for sharing your thoughts or suggestions in advance!
Relevant answer
Answer
Some DNA remain in the column's filter and if you use too much elution buffer it will be diluted. So, In the last step of DNA purification (DNA Elution), warm the buffer to 60 ºC and use as minimum as possible, like 15µl on the center of the filter (Don't touch the filter), then let to stand for 1 min. and spin at 9000xg for 1 min. repeat it with another 15 µl. 
  • asked a question related to C
Question
2 answers
If we take C*C on same time iteration we have penta-diagonal matrix where each and every element of matrix is penta-diagonal matrix ? and If we consider C(j)*C(j-1).it's become linear ? 
Relevant answer
The following book can help you
  • asked a question related to C
Question
6 answers
If we have two inputs x1 increases linearly from 0 to 10 and x2 from 0 to 1, and we need the output x3=x2 for x1<5, and for x1> 5 we need x3 to keep the last value at x1=5. All this in C-block.
If I put a counter and a matrix to keep the values of x3, C-block starts counting every time step. 
If you could help, I appreciate your time and effort, 
Relevant answer
Answer
int x[]={0,1,2,3,4,5,6,7,8,9,10}// value for x1
int y[]={0,1} // values for x2
for(int i=0<i<10;i++){
if(x[i]<5)
x[3]=y[2];
}
else
x[3]=x[1] }
/**** other codes *////
 }
  • asked a question related to C
Question
13 answers
Is there any source code in C/C++ to evaluate strings like eval() in Matlab and Python?
Relevant answer
Answer
Have a look at the Boost libraries, especially the Proto part: http://www.boost.org/doc/libs/1_64_0/doc/html/proto.html. It has an expression evaluator function eval().
  • asked a question related to C
Question
2 answers
I have introduced a Triangular slot on patch... i have got the eq. ckt of triangular patch ( R L C in parallel)..but not getting of triangular slot. can anyone suggest the equivalent (in terms of RLC) for slot.
Thanks
Nitin
Relevant answer
Answer
Thanks!! i have seen the web..but clueless about how to find RLC values and eq. ckt for triangular slot.. pls elaborate on this.. if possible can you email me at nmuchhal@gmail.com by screenshot of steps so that i can understandhow to do so for my specifications
Thanks Regard
Nitin
  • asked a question related to C
Question
3 answers
Hi there,
  Is there any scientists who are doing some researches on exosomes and know a good way to store the isolated exosomes? Basically, we store the exosomes with PBS in -80°C, but we are afraid that the exosomes will be distroyed if stored in  -80°C. Therefore, I am wondering if there are some good ways for the storage of exosomes, such as a specific buffer or something like that?
Many thanks!
Relevant answer
Answer
Hi, Igor, thank you so much!
  • asked a question related to C
Question
2 answers
Hi,
I have the Thermo Scientific HAAKE viscotester C, L-Version spindles, Type 399-0301, Serial No. 1110301006. I used it to measure the viscosity of different liquids using different spindles but at the same rpm. What is the conversion factor to calculate the viscosity of the  different fluids since I used different spindle for different liquids. Kindly assist me with the conversion factors to calculate the viscosity depending on the spindle used.
Thank you for your anticipated assistance.
Relevant answer
Answer
Thank you Alan for you response. I already contacted them and got feedback. Researchgate was just an alternative.
  • asked a question related to C
Question
4 answers
I have an instrument for which I colect data for the scales A and B. My final score it will be the scale C, which is a difference between A and B.
For the validation process, shoud I include the scales A and B, or only scale C?
If you have any examples for this, please let me know.
Thank you!
Relevant answer
Answer
In support of what Julia B. Smith has said Sabina for you to establish the validity of the instruments make sure you give the instruments to experts in that field, Psychometrians and Expert in English Language for their comments in relation to diction and sentence  construction. Finally trial - tested among selected subjects to determine its reliability and correlation co-efficent.
  • asked a question related to C
Question
3 answers
What is the funtion of C/N ratio or organic matter conent in determing the presence of a plant?
Relevant answer
Answer
First of all, Organic matter and C/N ratio are different
Organic matter is all volatile solid going to burn at high temperature (550)
C/ N ratio  is Carbon/ total Nitrogen
Generally OM/1.724 is equal to Carbon.
C/N ration is function of soil fertility.
Please revised your question.
  • asked a question related to C
Question
3 answers
I am looking for a library to be integrated in LabWINDOWS CVI.
Relevant answer
  • asked a question related to C
Question
5 answers
I need to assign a structure that has a Cl but my 1D and 2D aren't helping much.
  • asked a question related to C
  • asked a question related to C
Question
2 answers
Hi all
During hot press I am facing major problems in EPDM composites fabrication. Mixing temperature: 190 degree C for 15 minutes and hot press 200 degree C,. After the hot press, the EPDM cross composite material is sticking with the PI sheets placed up and down of the mould. How to get rid of this problem?. Does anybody have any suggestion?. I haven't added DCP. Is it because of absence of DCP in the cross composites? if yes, Can let me know what is right time to add DCP during mixing and at what temperature?
Regards
Relevant answer
Answer
Both the films: Underlay and overlay - should be made of Polyimide covered--laminated  by Teflon -then there will be no adhesion of cured EPDM to the hot press die - it's a common practice. THUS, you need to use a one-side-laminated by Teflon PI film. There are hundreds of manufacturers of such a films. 
Note that such a film withstands about 10 cycles of hot pressing
And then requires replacement.
It also seems to me that the difference between mixing temperatures (190C) and hot pressing (200C) is not enough.
It is more reliable to work if the temperature differs by 20-25 ° C
  • asked a question related to C
Question
1 answer
I call on  the assistant of all researcher in the site to help out with the article of "Jones, M. C. (2000). on A skew t distribution."
Relevant answer
Answer
Hello Samson, do you mean Jones, M. C. (2000). A skew t distribution. In: Charalambides, Ch. A.; Koutras, M. V. and Balakrishnan, N. eds. Probability and Statistical Models with Applications. London: Chapman & Hall/CRC, pp. 269–278? If so it is available on google books [https://books.google.de/books?id=gu3LBQAAQBAJ&lpg=PA269&ots=MpMJ-_XVVs&dq=Jones%2C%20M.%20C.%20(2000).%20A%20skew%20t%20distributio&lr&hl=de&pg=PA274#v=onepage&q=Jones,%20M.%20C.%20(2000).%20A%20skew%20t%20distributio&f=false]. What is your question?
Regards
 Felix
  • asked a question related to C
Question
5 answers
I have a complex metallic Alloy (Al-Cu-Fe) sample that is amorphous (solid and liquid) at 800'C which crystallization happens during the cooling process at 650'C. Can anyone help me to explain what is the reason behind this phenomena?
Relevant answer
Answer
Dear Hadi Parsamehr,
I agree with the remarks made by Hannes Engelhardt. Studying the relevant phase diagrams is of course the first thing to do in your case. However, varying the cooling rate implies that the kinetics of the (metastable) intermediate  phase formation will enter into the discussion. Besides, one has to invoke the possibility of crystal segregation yielding solidification routes that on principle deviate from the relevant equilibrium phase diagram. So good luck with your experimental study!
  • asked a question related to C
Question
3 answers
How can i calculate the thermal limit capacity of transmission line (data known with me (R, L, C ) and voltage rate in my work?
Relevant answer
Answer
I agree with the aforementioned answer by  Srete Nikolovski. Also, I would like to add that it is not only overhead lines. There is also a standard for insulated conductors and according to the installation method and ambien temperature then there are the corresponding de-rating factors. These are also included in British Standards for Wiring Regulations (BS 7671).
  • asked a question related to C
Question
4 answers
Unfortunately, I had to stope expression process for about 5 months and after this delay time I had to again to do some change in expression conditions I mean against before I used 25◦C to participate bacterial suspension. But after purification step, there was no band in SDS PAGE. I don’t know what is the wrong? Is this possible that this change in centrifugation temperature caused I lost my protein? My protein is HIV-1 Tat and Expression temperature is 37◦C for 4 hours and I use BL21DE3 and PET28(a).
do you have any idea? Please?
Relevant answer
Answer
thank you all for your informative answer.
  • asked a question related to C
Question
2 answers
Unfortunately, I had to stope expression process for about 5 months and after this delay time I had to again to do some change in expression conditions I mean against before I used 25◦C to participate bacterial suspension. But after purification step, there was no band in SDS PAGE. I don’t know what is the wrong? Is this possible that this change in centrifugation temperature caused I lost my protein? My protein is HIV-1 Tat and Expression temperature is 37◦C for 4 hours and I use BL21DE3 and PET28(a).
  • asked a question related to C
Question
4 answers
Hello,
Did anyone ever asses adipogenesis using the adiponectin ELISA kit from thermo fisher?How does it work?
Is it ok to store the cell supernatant inside eppendorf at -80°C until use?
Thanks
Benedetta
Relevant answer
Answer
Hello
i suggest use this kit ( Human Total Adiponectin/Acrp30 Quantikine ELISA Kit ) from R&D systems
kindly look at the links here
Good Luck
  • asked a question related to C
Question
4 answers
I'm looking for this article, THOM, E. C. The discomfort index, Weatherwise, v.12, v.2, p.57-61, 1959, however I didn't find it.
Does anyone can help me?
Thanks
Relevant answer
Answer
Obrigado, Profa.Mara.
  • asked a question related to C
Question
5 answers
Separation of epoxides using a B-bex column with acetonitrile as solvent and deterctor FID. The conditions are: oven temperature-max 70 ° C, injector 280 ° C, detector 220 ° C, pressure 38 psi. I used the method around 30 injections, all normal, when finishing one of them, the baseline jumps and generates a lot of noise, from there, in all the chromatograms the baseline shows the temperature ramp that I use. What happened to the column?
Blue line - normal chromatogram. Green line - first time it appears.
Purple line and aquamarine - chromatograms after the jump
Relevant answer
Answer
First off, do you mean a b-DEX column? That is a chiral phase, and has to be handled with great care. 
You claim to be running an analysis in acetonitrile but you show that your maximum temperature is well below the boiling point of the acetonitrile. As is obvious to anyone with any experience in chromatography this would simply not be possible. If this is the actual case then you need to completely change your analysis. If you truly are using ACN as your solvent (a very poor choice for GC, by the way) then you are building up solvent all through your system and you are probably flooding your detector. This is consistent with the chromatographic traces that you have shown.
Secondly, 220C for a FID is WAY too low. You will get all kinds of crazy things happen. Raise your detector temperature up to no less than your injection temperature. 280 C as an injection temperature for a maximum oven temperature of 70 C is WAY, WAY too high!!! Lower your injection temperature.
You are in a university environment. You clearly are in need of some very basic GC training. Surely your university has someone who actually knows something about GC? You should consult them.
  • asked a question related to C
Question
1 answer
So i have values of L and C here. And I need to length and width. Expressions are there in the file. But i am not able to understand how they calculated. So can someone please explain me how they got length and width of L and C using that root-searching program developed in this paper?
Relevant answer
Answer
for a generic lossless transmission line the characteristic impedance Zc=sqrt(L/C) and the phase velocity Vp=1/sqrt(LC). 
L and C are per unit length,so C=1/(Zc.Vp) which is (5) in the paper
and L=Zc/Vp which -for microstrip line- lead to that equation in the link 
or (6) ,(7) in the paper , all are approximations .
it's not easy to calculate the dimensions using these equations so the program solves it numerically 
  • asked a question related to C
Question
4 answers
By default if we use command graycomatrix the resultant we get is 8*8 matrix, But depending upon the problem this matrix should be changed
Relevant answer
Answer
you may use the following function
good luck
function joint_hist=find_joint_hist(image1,image2)
%% images should be gray-scale and with the same size
joint_hist=zeros(256,256);
for i=1:size(image1,1)
for j=1:size(imag1,2)
a=image1(i,j)+1;
b=image2(i,j)+1;
joint_hist(a,b)=joint_hist(a,b)+1;
end
end
end
  • asked a question related to C
Question
14 answers
I would like to know how to implement the basic concept of LBP operator with uniform patterns. I have implemented the basic concept of LBP operator in MATLAB. Now I am using the concept of uniform pattern.
The problem is that I am not able to understand the basic concept of LBP with uniform patterns. How exactly should it be done? Is there any documentation available which can help me?
Relevant answer
Answer
If you consider the standard LBP operator LBP_8_1, you can have 2^8 distinct values that a LBP can have. Should you create a histogram of these, you would have a 256 bin histogram. Now, should you consider their binary representation and consider only the ones with at most two jumps 0→1 or 1→0, you would have a total of 58 distinct ones (see the attached figure). If you create a histogram of these and place all others into a separate bin, you have a 59 bin histogram. Check out this paper and this figure for the details.
  • asked a question related to C
Question
5 answers
One of the most challenging aspects of developing the previous version of ForTrilinos was devising a reference-counting scheme to ensure safe type finalization in Fortran and corresponding object destruction in C++.  It's interesting to see that the SWIG-generated file forepetra.f90 on the new develop branch contains an Epetra_Object derived type with a type(c_ptr) component.  Will that component become associated with the C++ object that the Fortran object shadows?   Given that there's no final subroutine on the type, is there a strategy to avoid memory leaks and dangling pointers?  How will the C++ code get notified when the Fortran object goes out of scope so that C++ knows its safe to destroy the object?  How will the Fortran code get notified if C++ destroys the object?  
What will happen with an expression such as
type(Epetra_Object) :: a,b,c
a = f(b) + g(c)
where f and g are functions that have Epetra_Object results containing c_ptr components that presumably are associated with C++ objects that were instantiated at the direction of Fortran inside each function.  After the above assignment completes, the Fortran code no longer has a name associated with the two function results so the Fortran program has no way to direct C++ to destroy the corresponding C++ objects.
Damian
Relevant answer
Answer
Regarding 1, it's probably best to read the papers we wrote on the subject:
Email me if you have trouble accessing these and I'll reply with PDF's.  We were also awarded a related patent, which the Sandia intellectual property staff assured me posed no problems with using the algorithm in ForTrilinos:
Regarding 2, I'll be very curious to see the details of what you're describing.  When you write "a referenced counter pointer to C++ class," I assume assume you mean "a reference-counted pointer..."  The SWIG-generated forepetra.f90 file contains a Epetra_Object derived type with a type(c_ptr) component named "ptr".   Is this the reference-counted pointer to which you're referring?  If so, are you referring to a reference-counting scheme in Fortran or to the reference-counting scheme that already exists in C++?  If the reference counting scheme happens in Fortran, then it will be interesting to see how one can be generated with SWIG.  I don't see anything in the current SWIG output that suggests there's reference-counting happening.  If the only reference counting happens in C++, then I'm not aware of schemes to avoid dangling pointers and memory leaks other than the scheme we developed.  
It would probably be worthwhile to try compiling code like what is written in the clarification that I posted just after posting my initial question. Run the resulting executable through valfgrind and check for memory leaks. And also consider whether there are scenarios that could lead to dangling pointers. If C++ destroys an object, I don't think that automatically nullifies any type(c_ptr) pointers holding the C address of the C++ object.
Damian
  • asked a question related to C
Question
4 answers
Shaft speed is 3000 rpm and should carry 400 hp.
Relevant answer
Answer
In the field of steels I can suggest:
DIN W.Nr.1.5633 or 1.5637 : low alloyed steels with Nickel or a stainless steel like SAE 316.
You can find tables with the mechanical properties and the impact test data at low temperatures 
Regards
  • asked a question related to C
Question
3 answers
Hello everyone,
I want to measure the total nitric oxide in a serum sample using Total Nitric Oxide Assay Kit (enzo life sciences) and my question is about the proper storage procedure for the samples; do I have first to dilute and deproteinize the samples before storing them at -80 C ? or can I store serum samples at -80 C and perform the dilution and deproteinization step directly before the assay ? 
Thanks in advance!
Relevant answer
Answer
You can store the samples at -80 C but add DTE (as an antioxidant) and protease inhibitor cocktail to the samples.
You can pass the samples through 10KDa filters before analysis (This step gives better results). Good luck.
  • asked a question related to C
Question
7 answers
In POSIX multithreading, how can I provide high priority to my c program executable among other system processes? I have assigned priority to the threads using "pthread_attr_setschedparam()" by FIFO & RR, but I have failed to reduce scheduling delays while executing the algorithm. When the execution(performance) of the program is analyzed using perf tool the CPU idle time is high compared to its non-threaded counterpart of the algorithm. I am using Ubuntu on Intel i5 processor based system. Is there any other solution to overcome this problem? Whether using an RTOS will help? Is there an RTOS suitable for multicore system and what kind of development environment is required? 
Relevant answer
Answer
Anishchandran,
I just noticed your private message!  Sorry.   So I think I see the problem.
You have 3 overlapping loops which process arrays.   Processors use a hierarchical arrangement of caches to cache memory for more rapid access.   So if you have algorithms which force the CPU to pull in large swaths of memory, this can lead to inefficiencies depending on the arrangement of the data structures in memory.
So in a single threaded operation, in most operating systems, you will have cache affinity - the thread will be scheduled on the same core / CPU when possible in the hopes that come cached data from its prior time slice is still present.   This increases the lower level cache efficiency.   So  On accessing X[i] there is a better chance of X[i+1] being satisfied by the cache.
Now imagine a multi-threaded approach.
You have more demand placed on the cache - as the working set of data between all threads is increases - also you have several CPU hungry threads preempting each other.  So this can result in less cache hits in the lower level caches.
Now there is a huge degree of speculation in the above analysis.
You can prove this easily by artificially increasing the size of your arrays or data structures ( say you DOUBLE the number of array elements and use every other one. ) what this does is double the amount of memory pages to be accessed, while keeping the same number and size of data elements processed.   If caching is the issue, you will note progressively worse performance as the used are elements are sparser.
One way to test this is to create a debug fork of your code which multiplies the array indices on all of the arrays, so instead of X[i] = Y[i] * Z[j] you have X[i*n] = Y[i*n] * Z[j*n] all throughout your code.  Where n is your sparseness factor, 1,2,3, ... 
IF you see large performance differences for different values on n, you are seeing a cache dependent or performance issue.
So to  this:
Create data structures and computing patterns that exploit the CPU cache.  This is to say, making sure multiple threads are not accessing different portions of the data set, but instead work in lock step on the same areas of the data based on the data structures.  
Some times with large data sets where you rarely re-access the same data elements, like a summation operation, a single threaded approach is OK, or an approach where you split up the data into multiple subsets - based on the number of cores you have or the architecture of the cache.
-- Bob
  • asked a question related to C
Question
3 answers
Hello,
I am using TriLink's Mutagenesis dNTP mix to perform EPR on a 1.3 kb fragment. I have been unable to observe a PCR product when following their recommended cycling parameters. I am able to successfully amplify my product using Phusion so my template and primers seem to be fine. 
Cycling Conditions:
95 C - 3 min - Initial denaturation
92C- 1 min/53 C - 1.5 min/72 C - 5 min x 30
72 C - 10 min - Final extension
Components: 10x PCR buffer, 500 nM Forward/Reverse Primer, 10 fmol template, Mutagenesis dNTP mix, 2 mM MgCl2, Taq (5U/uL), water up to 25 uL
Any troubleshooting tips?
Relevant answer
Answer
Hello Sushanth
Try a gradient PCR (48,50,52,54,56,58) and see if their is any amplification.
  • asked a question related to C
Question
1 answer
Let $M$ be a totally real submanifolds of product Kaehler manifold
$\overline{M}(c_{1}, c_{2}) = \overline{M}^{n}(c_{1}) \times \overline{M}^{p}(c_{2})$
with $c_{1}$, c_{2} > 0 and tr(P - Q) = 0, where $P$ and $Q$ are the projection operators of the tangent space of $\overline{M}(c_{1}, c_{2})$ to the tangent spaces of $\overline{M}^{n}(c_{1})$ and $\overline{M}^{p}(c_{2})$ respectively. Can $M$ be a totally geodesic in $\overline{M}(c_{1}, c_{2})$ ?
                                      OR
Can $M$ be a totally geodesic submanifold of $\overline{M}(c_{1}, c_{2})$ under certain other conditions ?
Relevant answer
Answer
we did it for cosymplectis.
1. Siraj Uddin, V.A. Khan and Cenap Ozel, A classification of totally umbilical ξ^⊥ CR-submanifolds of cosymplectic manifolds, Rocky Mountain Journal of Mathematics (accepted) (ISI-Cited Publication) - http://projecteuclid.org/euclid.rmjm/1374758609
2. Siraj Uddin and Cenap Ozel, A classification theorem on totally umbilical submanifolds in a cosymplectic manifold, Hacettepe Journal of Mathematics and Statistics, (Accepted) IF=0.354 Q4-ISI (ISI-Cited Publication
  • asked a question related to C
Question
4 answers
I wanna to find the modulus from ultrasonic pulse velocity or (ASTM C 597) 
Relevant answer
Answer
dear, oskar baggen
thank you so much 
  • asked a question related to C
Question
3 answers
I am working on Processor-Pool model for a project. Here are some assumptions:
1. Users have a low-end system.
2. They want to use an application which requires high-end workstations.
3. They need real-time graphic(visual) updates.
I was wondering if it is possible to do this without screen capture or TeamViewer, or RealVNC, or Red5 like software. I came across an idea to develop a network display model through the following method:
a. The user has a small software installed on their system which is connected via sockets to the server. Each user input is sent to the server(This is where Processor Pool model come into play).
b. Like cloud gaming services, the input is processed and the display is generated. But instead of sending video output we generate a file which is sent to the user.
c. The user receives this file and the small software installed on his system generates the final display output.
Now my question is what might be the extension of file highlighted above. Conventionally we have the file with extensions like JPG/ AAC/ H.265 codec/ etc.
Is it possible to generate a JSON for the file and which when received by the software at the user end generates the desired display output?
Please post your queries, if you have any. I am looking forward to discussing with all the great people out there.
Note: I am not looking for Screen Capture solutions. And a big TIA
Relevant answer
Answer
I believe that you are trying to reinvent something that already exists, which is fine! But, in this particular instance, VNC as a server-client method is pretty much what you ought to find sufficient for your explained use-case scenario.
The server can run a virtual screen which renders the application that demands a a lot of processing power to run (which the serve supplies one way or another) and the client is just a dumb terminal capable of performing minimal data decoding at some phase and showing it on the physical screen.
The method you've proposed (using JSON and JPEG) suggests that you want to send frame-by-frame data, which can be troublesome in terms of bandwidth, required down-link speed and inability to perform multi-frame compression (between key-frames).
VNC allows all of this. It is efficient, optimised, has different modes for different targeted frame-rates and display content change dynamics.
Your proposed method would have to be designed and developed from scratch, which is, in this particular instance, probably a waste of your time and resources.
Of course, VNC is not the only possible solutions. There are others, but they are all probably much better suited than an own (new) solution, unless the application itself (that will be ran on the server) can directly create a stream of video data and push it to the client, completely skipping the need for a virtual display. This, however, requires a specialised application made specifically to function that way.
  • asked a question related to C
Question
3 answers
in the link of github sha transform has two arguments ctx and byte data[], what is data[] meant for and in the next line wat is i and j and why shifts are done of 24,16,8 and why j added with 3
next step what states mean here and according to what i know that first 16 rounds would be copying the m[16] and next 48 that computations of sigma and all would be done but in this program why direct 64 rounds that are done  and iteration starting from 0 to 64
what are bitlen and bitdata referring too...whybilen added with 512 in if part
and atlast final is completely a  grrek for me i could understand is somewhere padding is done but why if and else part are done with 56 and 64 i donno
and why memset has been used . at last step appending to padding tha message in bits and transform and last steps are completely out of my head now....sorry to ask the question mant times but need some guidance to understand and to work on because im not so strong in c
Relevant answer
Answer
24, 16, 8 these are used to represent the number of bits used in Hash function. Data[] is used for initialized the string used for encryption.
Data[] is used for initialized the string used for encryption.
ctx is a pointer used for naming conversion.
  • asked a question related to C
Question
9 answers
i have gone through all this links..but im not understanding the link which i have uploaded..i have to make changes in opencl code thta is implemented in sha256.for that proper undestanding of sha256 is needed..in the link which i uploaded can anyone help in explaing me wat happens in the program.
Relevant answer
Answer
Dear Thiruman,
I am not an expert on hashing algorithms, but as I told you before, you should not start studying a subject by reading a code, if it is too complex. I would advise you reading a book or something like that. From the Wikipedia page I linked earlier, I found a good description (see below).
Hope it helps!
  • asked a question related to C
Question
3 answers
Do x,y,z values defined in UDF take the same x,y,z values of the main geometry in Fluent or does it depend on some flow like x is always for fluid flow etc?
Also, how to know if the UDF follows the origin of the required boundary surface ?
Attached is the UDF I have tried to code.
#include "udf.h"
DEFINE_PROFILE(inlet_temp,thread,position)
{ float x[ND_ND]; /*hold position vector*/
float y;
float r;
float x2;
float y2;
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
y=x[1];
x2=pow(x[0],2);
y2=pow(x[1],2);
r=pow(x2+y2,0.5);
F_PROFILE(f,thread,position)=/*..r*/;
}
end_f_loop(f, thread)
}
Relevant answer
Answer
Dear Gargi,
yes, x,y and z coordinates defined in the UDF are the same of Fluent since you are referring to the imported geometry.
Anyway, you can double check the x, y and z values of your UDF including a "printf" instruction to have a visual confirmation in the Fluent TUI.
Best regards,
Simone
  • asked a question related to C
Question
24 answers
I want to know if there is any IDE for C/C++ which could help in easy debugging of a large C/C++ project in Mac.
I have tried Netbeans but it doesn't help although there is debugging process there but as it encounters any error it stops all of a sudden without giving any details about the line number where error is occurring.
Relevant answer
Answer
you can find more than your answer here!
I hope it will help you
  • asked a question related to C
Question
1 answer
I would like to emulate various n-bit binary floating-point formats, each with a specified e_max and e_min, with p bits of precision. I would like these formats to emulate subnormal numbers, faithful to the IEEE-754 standard.
Naturally, my search has lead me to the MPFR library, being IEEE-754 compliant and able to support subnormals with the mpfr_subnormalize() function. However, I've ran into some confusion using mpfr_set_emin() and mpfr_set_emax() to correctly set up a subnormal-enabled environment. I will use IEEE double-precision as an example format, since this is the example used in the MPFR manual:
mpfr_set_default_prec (53);
mpfr_set_emin (-1073); mpfr_set_emax (1024);
The above code is from the MPFR manual in the above link - note that neither *e_max* nor *e_min* are equal to the expected values for `double`. Here, p is set to 53, as expected of the double type, but e_max is set to 1024, rather than the correct value of 1023, and e_min is set to -1073; well below the correct value of -1022. I understand that setting the exponent bounds too tightly results in overflow/underflow in intermediate computations in MPFR, but I have found that setting e_min exactly is critical for ensuring correct subnormal numbers; too high or too low causes a subnormal MPFR result (updated with mprf_subnormalize()) to differ from the corresponding double result.
My question is how should one decide which values to pass to mpfr_set_emax() and (especially) mpfr_set_emin(), in order to guarantee correct subnormal behaviour for a floating-point format with exponent bounds e_max and e_min? There doesn't seem to be any detailed documentation or discussion on the matter.
Here is a small program which demonstrates the choice of e_max and e_min for single-precision numbers.
#include <iostream>
#include <cmath>
#include <float.h>
#include <mpfr.h>
using namespace std;
int main (int argc, char *argv[]) {
     cout.precision(120);
    // Actual float emin and emax values don't work at all
    //mpfr_set_emin (-126);
    //mpfr_set_emin (127);
    // Not quite
    //mpfr_set_emin (-147);
    //mpfr_set_emax (127);
    // Not quite
    //mpfr_set_emin (-149);
    //mpfr_set_emax (127);
    // These float emin and emax values work in subnormal range
    mpfr_set_emin (-148);
    mpfr_set_emax (127);
    cout << "emin: " << mpfr_get_emin() << " emax: " << mpfr_get_emax() << endl;
    float f = FLT_MIN;
    for (int i = 0; i < 3; i++) f = nextafterf(f, INFINITY);
    mpfr_t m;
    mpfr_init2 (m, 24);
    mpfr_set_flt (m, f, MPFR_RNDN);
    for (int i = 0; i < 6; i++) {
        f = nextafterf(f, 0);
        mpfr_nextbelow(m);
        cout << i << ": float: " << f << endl;
        //cout << i << ": mpfr: " << mpfr_get_flt (m, MPFR_RNDN) << endl;
        mpfr_subnormalize (m, 1, MPFR_RNDN);
        cout << i << ": mpfr: " << mpfr_get_flt (m, MPFR_RNDN) << endl;
    }
    mpfr_clear (m);
    return 0;
}
With thanks,
James
Relevant answer
Answer
There are different conventions to express significands and the associated exponents. IEEE 754 chooses to consider significands between 1 and 2, while MPFR (like the C language, see DBL_MAX_EXP for instance) chooses to consider significands between 1/2 and 1 (for practical reasons related to multiple precision). For instance, the number 17 is represented as 1.0001·24 in IEEE 754 and as 0.10001·25 in MPFR. As you can see, this means that exponents are increased by 1 in MPFR compared to IEEE 754, hence emax = 1024 instead of 1023 for double precision.
Concerning the choice of emin for double precision, one needs to be able to represent 2−1074 = 0.1·2−1073, so that emin needs to be at most −1073 (as in MPFR, all numbers are normalized).
As documented, the mpfr_subnormalize function considers that the subnormal exponent range is from emin to emin+PREC(x)−1, so that for instance, you need to set emin = −1073 to emulate IEEE double precision.
  • asked a question related to C
Question
1 answer
Hi
I have a problem in my transformation part of project
after preparation of competent cells and transformation nothing growth in plates
protocol of competent cell is this
5ml of renewed bacteria in LB broth in certain OD
centrifuge 3000rpm 3min - remove liquid part
add 1ml of CaCl2 and re suspend  .incubate 30 mins on ice
centrifuge 3000rpm 3min - remove liquid part
add 670 MicL CaCl2 and re suspend . incubate 30 mins on ice
centrifuge 3000rpm 3min - remove liquid part
add 300 MicL of CaCl2
incubate on ice 30mins
heat shock 45sec in 42`C
immediately transfer tube on ice 2mins
add 900 MicL LB medium
incubate 4 hours in falcon tube in 37`C shaking  190 rpm
then culture in this medium :
LB Agar + Kana(50Micg/Ml) + tetra (10Micg/Ml)+ 100micg/ML X-Gal)+7micg/Ml gentamycin + 40 micg/ml IPTG
but nothing growth after 48hour in 37`C
what is your advise or where is the problem  
Relevant answer
Answer
Hi Amir,
Firstly, for making competent cells, one of most critical parameter is the right O.D at 600 nm., It is generally recommended to be between 0.2 and 0.5. Ideally the mid log phase cells OD 0.5 works just best.. I would like to tell you that there is a competency buffer (CCMB80) for preparing DH10Bac and as a good practice I would advice you to stick to that buffer. You may find the details online.
But, why did you heat shock the cells without adding any DNA, I hope your intention was to transform these prepared competent cells to test their Transposition efficiency!! For transformation with donor construct, use 100ng DNA..
Secondly, It is important that you confirm the selection marker (Gentamicin or Ampicillin) on your transfer vector., and supplement the drug along with the culture medium when you prepare plate.
Hope this Helps!
Good Luck :)
  • asked a question related to C
Question
4 answers
I have been looking at the "convolutionSeparable" code sample provided with CUDA 7.5, for the implementation of a 2-D FIR filter for image processing. 
The rationale behind the design is discussed in the link.
Has anybody else looked closely at this code and found possible improvements or have any other comments/thoughts? 
Relevant answer
Answer
OK. This is what I have found so far ...
The attached design doc all makes sense (but I would disagree that "convolution measures the amount of overlap between two functions"). However, I found the sample code difficult to follow. So I wrote my own ...
I used the sample code as a performance benchmark and eventually I was able to match it. I found the profiler to be more reliable than timer calls for quantifying execution speed.
Yes, using shared memory improves performance, despite the extra code and (wasted) threads required to populate it. 
My code was much more compact than the sample code. Why are loops used to populate the shared memory tile in the sample code? I just used a single thread to populate each element, before proceeding to the convolution (after syncing threads in the block).
My code runs at around 100% GPU occupancy compared with 50% for the sample code, yet the execution time is roughly the same (?). 
My row and col calls have approximately equal run times, whereas the sample code run times are very different in each dimension so the total run time will depend on the image aspect ratio!
In my code, I zero out the edge effects around the perimeter of the image.
I'll post my code later, if there is any interest.
  • asked a question related to C
Question
4 answers
Let f be an involutive (f(f(x)) = x) function from R>0  to R>0 such that f(1) = c, (then f(c) = 1).
I have obtained the following f(f(x)f(y))/xy = f(xy)/f(x)f(y), by setting f(y) = 1, we get f(xy) = f(x)/y. How to prove that this is valid for all y>0?
I have used the injectivity of f. Note that f is a bijection, and f(y) = 1 for y = c.
The function in the question is f(x) = c/x.
Relevant answer
Answer
Dear Mr Stoica,
I thank you for your reply. The functional equation I considered is not of a logarithmic type. It is a Babbage type.
  • asked a question related to C
Question
7 answers
Hello Everyone,
I want to scale down a 16 bit unsigned data into a range of 0 to 255 in C.
Can any body guide me how i can achieve this?
Looking forward for reply!
Best Regards
Awais
Relevant answer
Answer
In order to divide by 256, shift
the number right 8 bits.
Use >> 8.
Regards,
Joachim
  • asked a question related to C
Question
18 answers
I need to import residual stress field into my model using the Predefined filed option and output database file. Everythin is ok until I need to start the calculation when it says; The following file(s) could not be located: "C:/....." . But file is there of course. Do you know maybe where is the poblem?
Best,
Darko
Relevant answer
Answer
In the meantime I found the solution. File is needed to be in the ORIGINAL Abaqus temp folder. In my Abaqus I change the location of the temp folder, but for the predefined field input the file is needed to be in the original one which is in C:\Users\name\AppData\Local\Temp
 Thank you on all your help and whish you all the best.
Darko
  • asked a question related to C
Question
5 answers
I have designed a testing approach to test integration fault of embedded system. I have already created the test criteria. But now i need to go for experimentation but i do have any sample code. I need some real C code which i can execute with test cases. I tried to search in many sites but did not get suitable code.
What should i do now? Because without execution i cannot collect the test result. Please share your idea.
Thank you.
Relevant answer
Answer
Hi Muhammad, 
  You can have a look at open source C projects in gitHub. 
  • asked a question related to C
Question
5 answers
In many articles, the transmitter sends data with a rate (R)<the outage capacity(C), and then the receiver can correctly decode the codewords.
If there is only 5 bits, and these bits are all destroyed by the noise. So, how the receiver recovers them? Because the noise is randomly.
Relevant answer
Answer
Dear @Jie Shi, 
Shannon's theory is formulated under the assumption of there is something transmitted over the channel, of course, if everything is corrupted, you will have any data on the receiver to draw any conclusion. Under Shannon's formulation, you can make a communication scheme (coding, symbols, etc) to make the probability of error arbitrarily small. Of course, if all is lost, this is over. Eventhough, it is remarkable Shannon's work, it states that even over a really noisy channel, Perror = 99/100, you can come up with a communication scheme to make the probability of error really small.
The key point is, Shannon's doesn't talk about 100% correct decoding of a message, it is said as close as you want to 100%, which is slightly different.
  • asked a question related to C
Question
1 answer
Hello Everyone,
I want to implement elliptical low pass filter in C.
But i am finding difficulty in it.
Can any one please guide me how i can implement it?
Looking forward for your reply.
Best regards
Awais
Relevant answer
Answer
Dear Researcher
in addition to the above answer ,m sending you a link where you can find some more filters implementation in c.hope it will help you.
Regards
  • asked a question related to C
Question
4 answers
I want to extract data directly from LIRT/HRIT data received from GOES Satellites and be able to process the fields in it. Maybe a reference of the standard data codification in LRIT/HRIT files will be also helpful for me.
Relevant answer
Answer
I've heard of pytroll:
Take a look at this page:
They're listing some processing tools for meteorological data.
I'm aware of zyGrib which is an open source grib viewer, maybe it has some plugins for xRIT format you could easily use.
  • asked a question related to C
Question
1 answer
I found bouncy castle, is that preferable?
Relevant answer
Answer
This is an old questions, but I will bite anyway.
"Best" is always a subjective judgement, and in my answer I am not going to take a position and to declare a "winner". Let's just say that "best" is what gives you the results you regard as superior, and you need to find this out by trying all the alternatives and comparing the results. So if you were hoping to start a flame war, or to get a canned reply, tough luck.
I would, first of all, consider the cryptography library already available in .NET (in System.Security.Cryptography). Now that Microsoft has released most of the .NET source code, only paranoid programmers should object to trusting .NET on the basis of hypothetical backdoors and weaknesses planted into the source code by secret services. Unless you need functionality that is not part of the .NET library, I see no real need to look for a third-party product, and there are many reasons why you should not develop your own crypto API. Also, before wasting time with the internal workings of the Microsoft Crypto API 1.0, google "Cryptography API: Next Generation".
A good part of the .NET System.Security.Cryptography namespace is already available in Mono, but not all. Depending on what you need, you might be able to use Mono instead of .NET.
Bouncy Castle has been criticized by some as being a museum of old algorithms, several of them of dubious practical usefulness today. Nonetheless, it seems to be popular among some programmers, especially those who don't know .NET well enough to be aware of what it offers.
SecurityDriven.NET/inferno is another possibility. I know very little about it, however, it is so small that it is likely a simplified wrapper of a selected part of the .NET crypto functionality. If you like it, use it. If you don't, use the .NET functionality directly.
  • asked a question related to C
Question
15 answers
Vibation analyzer in Measurement, Diagnosis and Speech Recognition use a state machine for event-driven control. Which programming language is the best for a software-state-machine in event-driven audiosignalprocessor?
Relevant answer
Answer
Sir,
Everyone is best with the language they know the best. You mentioned a state machine, I would suggest LabVIEW using a Queue Driven State Machine (QDSM) approach. In this approach, you dedicate a Queue to each major function (GUI Input, GUI Output, File input, File Output, Data Acquisition, Preprocessing data, processing data, report generation, etc). Each of these Queues will be able to communicate with each other queue through queue commands or events. The entire project could have a script queue that would allow it to be scripted from a text file (something I often do to allow reusability of the code).
I find that I can handle projects with over a thousand subroutines / SubVIs  by myself using this method. So little outside help is needed once you get some experience with it.
Good Luck!!!
  • asked a question related to C
Question
2 answers
I work on CORDIC-based DCT Structures and I want to know the main difference between Unfolded CORDIC and Lookahead CORDIC structures. Is there any difference between these structures?. These structures have been described in the following references.
[1]  M.-W. Lee, J.-H. Yoon, and J. Park, "Reconfigurable CORDICbased low-power DCT architecture based on data priority," VeryLarge Scale Integration (VLSI) Systems, IEEE Transactions on, vol. 22, pp. 1060-1068, 2014.
[2] C.-C. Sun, S.-J. Ruan, B. Heyne, and J. Goetze, "Low-power and high-quality Cordic-based Loeffler DCT for signal processing,"Circuits, Devices & Systems, IET, vol. 1, pp. 453-461, 2007.
Relevant answer
Answer
Dear Sir,
- The cordic algorithm is typically used to
  (a.) given (z, alfa) calculate x = z cos(alfa) and y = z sin(alfa)
  (b) given x = z cos(alfa) and y = z sin(alfa), calculate z and alfa
- During the cordic algorithm, there are 3 variables maintained:
  x1, y1, alfa1, and then there are transforms done that leave atan(y/x) + alfa constant, and result is a fixed amplitude growth during the transform. - The transformations done are rotations over a certain angle:
  x1 = x1*cos(angle1) - y1*sin(angle1)
  y1 = y1*cos(angle1) + x1*sin(angle1)
  alfa1 = alfa1 - angle1
- this is then modified into:
  x1 = cos(angle1) * (x1 -y1 *tan(angle1))
  y1 = cos(angle1) * (y1 + x1 * tan(angle1))
  alfa1 = alfa1 - angle1
- There are two forms in which this algorithms is used.
  (a) start with x1 = z, y1 = 0, alfa1 = alfa, and then iterate until alfa1 = zero
  (b) start with x1 = x , y1 = y, alfa1 = 0 and iterate until y1 = zero
- The iterations will use different angles, wherefor tan(angle1) are powers of 2.
   - 1. + or - 90 degree
     2. + or - 45 degree
     3. + or - atan(0.5)
     4. + or - atan(0.25)
- The sign is selected so that either y or alfa go to zero (convergence). The angles are selected such that the multiplication with the tangent is trivial.
- As the +/- sign has no effect on the value of the cos, and the cos only results in a fixed growth of the magnitude of the vector (which is independent of the rotation angle), it is omitted, and the algorithm is simplified to:
x1 = x1 - y1 * tan(angle1)
y1 = y1 + x1 * tan(angle1)
alfa1 = alfa1 - angle1
Now, an 'unfolded cordic' has hardware for every iteration. It has three full adders (one for X, one for Y, one for alfa) for each step of the algorithm. It can execute the algorithm in one clock (when not pipelined.)
A 'folded cordic' maps more steps of the algorithm on the same full adders, and has registers and feedback for this, and also the atan value is selected by a multiplexer as one set of full adders need to represent multiple atan values.
The drawback of the 'unfolded' cordic is the cascade of full adders. If you have eg a 10 iteration cordic, there is a cascade of 10 full adders, and their carry is slow. A 'lookahead' cordic has means to speed up the carry. (I did not find details there.)
Please note, that while the cordic looks nice on paper, the multiple carry paths in the  'unfolded' cordic are a problem. To do the transform x = z cos(alfa) and y = z sin(alfa), you should also consider alternate methods using multipliers. Using multipliers means more logic, but less carry propagation, and this may be faster than the cordic.
Cheers ,
Henri
  • asked a question related to C
Question
5 answers
I'm looking for Linux command-line tools (or, even better, routine libraries in C/Fortran/Pascal) calculating knowledge-based protein structure quality scores. I know procheck - that'll suit me well, but I do not need the multitude of PostScript plots it creates, because I am looking forward to process millions of protein conformations and to obtain a robust ranking by this knowledge-based "goodness" score, in complement to classical force field energies. Do you have any knowledge of a way to switch .ps file generation off in procheck? Do you know other similar tools which just focus on scoring, not on detailed reporting?
Relevant answer
Answer
I have used modeller to generate a pdb file. i have run it on PROCHECK. but the input format is not compatible. (brook haven format). how to convert my file? or any other way? Please help. 
  • asked a question related to C
Question
1 answer
I am optimizing an organic molecule on a CdSe cluster with Gaussian. However, the organic molecule is completely dissociated to its atoms in the final geometry. I am not sure about the basis set of Se. I have also tried the 6-31G basis for Se but I have the same result.
here is the input file
1 1
Cd 0.44201800 3.32548000 -0.38103700
Se 1.77943700 5.41809200 0.42354100
Se 1.57838900 1.12282200 0.43872800
Se -2.04088600 3.44451900 0.41648100
Cd 4.26234600 5.29905600 -0.37396700
Cd 4.06129800 1.00378400 -0.35878100
Cd 0.24097100 -0.96978900 -0.36585100
Cd -3.17725700 5.64717800 -0.40328400
Cd -3.37830600 1.35190600 -0.38809900
Se 5.39873800 3.09639500 0.44576500
Cd 7.88157800 2.97736200 -0.35171600
Se 5.19767900 -1.19887200 0.46095700
Cd 7.68055000 -1.31791100 -0.33653900
Cd 3.86024800 -3.29148700 -0.34360200
Se 1.37734100 -3.17244900 0.45391100
Se -2.24193600 -0.85075400 0.43166700
Cd 0.03992200 -5.26506000 -0.35066500
Cd -3.57935300 -2.94336500 -0.37291300
Se -5.66016200 5.76621400 0.39423300
Cd -6.99758400 3.67360100 -0.41034400
Se -5.86120900 1.47094200 0.40942100
Cd -7.19863200 -0.62166800 -0.39516000
Se 9.21905900 5.06997500 0.45285000
Se 9.01801000 0.77469500 0.46803600
Se 8.81695100 -3.52057400 0.48322500
Cd 7.47951900 -5.61318300 -0.32135800
Se 4.99662400 -5.49414400 0.47615900
Se -2.44298400 -5.14602400 0.44685400
Se -6.06225900 -2.82432900 0.42460600
Cd -7.39968100 -4.91693900 -0.37997300
Se -9.48048900 3.79263900 0.38717400
Se -9.68153800 -0.50263100 0.40235900
Se -9.88258500 -4.79790300 0.41754500
H 10.53166000 4.79103000 -0.22125300
H 10.31229300 0.73905500 -0.27810300
H 10.17197100 -3.50791000 -0.15120800
H -10.44276800 -6.08635800 -0.11884900
H -10.18311300 -1.79294200 -0.18051200
H -9.79474600 2.33395800 0.20839800
C -4.54000088 -1.38915111 -2.57307321
C -3.27539888 -1.91048011 -2.57303221
C -2.10958788 -1.07805311 -2.57304621
C -2.32662788 0.34240089 -2.57308921
C -3.59697288 0.88197689 -2.57312421
C -4.74684188 0.03606289 -2.57313321
C 0.49572012 0.34240089 -2.57307621
C 0.27868012 -1.07805311 -2.57302921
C 1.44449012 -1.91048011 -2.57298921
H 1.27521112 -2.98067111 -2.57292121
C 2.70909212 -1.38915211 -2.57301421
C 2.91593412 0.03606189 -2.57309321
C 1.76606512 0.88197689 -2.57309721
H -5.38856388 -2.05818911 -2.57301021
H -3.10611888 -2.98067011 -2.57296921
H -3.71511288 1.95693089 -2.57318421
H 3.55765512 -2.05819011 -2.57293521
H 1.88420512 1.95692989 -2.57313321
S -0.91545388 1.48302789 -2.57310821
N -0.91545388 -1.69791411 -2.57301221
C -7.18936988 -0.31836711 -2.57341621
C -6.20880388 2.01966989 -2.57289821
H -7.21172088 -0.95315611 -1.68118021
H -8.08499788 0.30027589 -2.57407021
H -7.21088288 -0.95374111 -3.46524321
H -5.76981188 2.48001089 -1.68069621
H -5.77021388 2.48032089 -3.46514321
H -7.27720988 2.22744389 -2.57261121
C 5.35846212 -0.31836611 -2.57321721
C 4.37789512 2.01966989 -2.57294621
H 5.38006512 -0.95378711 -3.46500821
H 6.25409012 0.30027789 -2.57381321
H 5.38072612 -0.95310711 -1.68094521
H 3.93908312 2.48028989 -3.46509621
H 3.93912312 2.48004089 -1.68064921
H 5.44630112 2.22744489 -2.57294521
N -6.00221388 0.55965989 -2.57318121
N 4.17130612 0.55965989 -2.57314521
X 1 F
X 2 F
X 3 F
X 4 F
X 5 F
X 6 F
X 7 F
X 8 F
X 9 F
X 10 F
X 11 F
X 12 F
X 13 F
X 14 F
X 15 F
X 16 F
X 17 F
X 18 F
X 19 F
X 20 F
X 21 F
X 22 F
X 23 F
X 24 F
X 25 F
X 26 F
X 27 F
X 28 F
X 29 F
X 30 F
X 31 F
X 32 F
X 33 F
X 34 F
X 35 F
X 36 F
X 37 F
X 38 F
X 39 F
H N S 0
6-31+G*
****
Cd Se 0
LANL2DZ
****
Cd Se 0
LANL2DZ
Relevant answer
Answer
 Are you sure about  monolayer CdSe with terminating with (Pseudo)  hydrogens  ?
If you are really continue with above structure. I hope you should try different orientation. The above guess is may not be near to local minima.
I hope you should go for PW based codes with PBC (for. e.g. QE or VASP) with including multiple (optimized) slab). Then, you place proper orientation of organic molecule providing sufficient vacuum. You can go for pseudopotential method instead of localized bassis
Regards
Subrahmanyam
  • asked a question related to C
Question
3 answers
Hi, I am working on sliding mode controller in robotic manipulators. Does anybody know how to write the code in c language? Please help me.
Relevant answer
Answer
"Applied Non-linear Control" is a good reference for sliding mode controller design. The algorithm is completely described
  • asked a question related to C
Question
3 answers
Do you know any open source tool to migrate C to Java?
Relevant answer
Answer
It is possible to use your C program in Java by using java native interface JNI.
  • asked a question related to C
Question
9 answers
Please give an opinion for my question, thank you. 
Relevant answer
Answer
As already stated, it is perfectly possible to program the Arduino board w/o the IDE. But keep in mind, whenever you plan using high-level languages such as C/C++ in the domain of µController you might suffer performance penalties in contrast to low-level assembly programming.
Furthermore you will have to deal with the specific port names (as the link from Oussama Kaoui already states). But in fact "breaking free" from the Arduino IDE is a good idea.
Best wishes - Kenneth :)
  • asked a question related to C
Question
8 answers
How to implement abstraction mechanism in c++ , what are the different types of abstraction mechanisms? I need some examples to understand.
Relevant answer
Answer
Here is an example that my students have found helpful.  First, build an abstract superclass representing generic employees:
---
class Employee {
public:
  Employee(const string& name, unsigned id) { myName = name; myID = id;}
  string getName() const { return myName; }
  virtual double getPay() const = 0;
  void writePayCheckTo(ostream& out) const
  { out << myName << " (" << myID << ") " << getPay(); }
 
private:
  string myName;
  unsigned myID;
};
---
Then build a subclass for salaried employees:
---
class SalariedEmployee : public Employee {
public:
  SalariedEmployee(const string& name, unsigned id, double salary)
  : Employee(name, id), mySalary(salary) {} 
  double getSalary() const { return mySalary; }
  virtual double getPay() const { return mySalary; }
private:
  double mySalary;
};
---
and another subclass for hourly employees:
---
class HourlyEmployee : public Employee {
public:
  HourlyEmployee(const string& name, unsigned id, double hours, double wage)
   : Employee(name, id), myHours(hours), myWage(wage) {} 
  double getHours() const { return myHours; }
  double getWage() const { return myWage; }
  double getPay() const {
     double result = myHours * myWage;
     if (myHours > 40) {
        result += (myHours - 40) * myWage * 0.5;  // add in overtime
     }
     return result;
  }
private:
   double myHours, myWage;
};
---
Then a simple program that uses the classes:
---
#include <iostream>
using namespace std;
// ... class declarations go here
int main() {
   Employee* emp1 = new SalariedEmployee("Jane", 01, 500.00);
   Employee* emp2 = new HourlyEmployee("John", 02, 42, 10.00);
   cout << emp1->getPay() << '\n'
        << emp2->getPay() << '\n';
 
   emp1->writePayCheckTo(cout); cout << '\n';
   emp2->writePayCheckTo(cout); cout << '\n';
}
---
The output from the program is:
  500
  430
  Jane (1) 500
  John (2) 430
Employee is an abstract class because its getPay() method is a pure virtual method (i.e., abstract).
The calls to getPay() within main() are polymorphic, but require no cast because Employee contains an abstract declaration of getPay().
The writePayCheckTo() method is only defined in Employee, so it is inherited, but it calls the polymorphic getPay() method, which is bound at runtime to the definition in the subclass of the object on which writePayCheckTo() is invoked.  (This example assumes the U.S. practice of hours beyond 40 earning overtime pay at 1.5 the usual rate.)
  • asked a question related to C
Question
6 answers
Result: The number of compositions of 2n, say c_1+c_2+...c_k=2n, satisfy that Sum_(i=1..j) c_i <2j for all j=1..k is equal to C(2n-1, n), i.e., the number 2n-1 choose n.
E.g., when n=2, C(3, 2)=3 because we can write 4=1+1+1+1=1+1+2=1+2+1.
Is there an easy way to prove it directly?
Relevant answer
Answer
To Ricky,
Just to clarify... your example is for n=2, so 2n=4 and you found 3 compositions with the formula C(3,2). Looks like C(2n-1,n) instead of C(2n+1, n+1). Tried it too for n=3 and it gives C(5,3)=10 compositions. With no + signs to make it short : 111111, 11112, 11121, 1113, 11211, 1122, 1131, 12111, 1212 and 1221.
  • asked a question related to C
Question
5 answers
close all
clear all
clc
a= rand(1e6,1);
b= rand(1e6,1);
c= zeros(size(a));
tic
tstart=tic;
for i=1:length(a)
c(i)=a(i)+b(i);
d(i)=c(i)+b(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
e(i)=d(i)+c(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
c(i)=a(i)+b(i);
d(i)=c(i)+b(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
e(i)=d(i)+c(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
c(i)=a(i)+b(i);
d(i)=c(i)+b(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
e(i)=d(i)+c(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
end
t_normal_for=toc(tstart)
tstart=tic;
parfor i=1:length(a)
c(i)=a(i)+b(i);
d(i)=c(i)+b(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
e(i)=d(i)+c(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
c(i)=a(i)+b(i);
d(i)=c(i)+b(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
e(i)=d(i)+c(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
c(i)=a(i)+b(i);
d(i)=c(i)+b(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
e(i)=d(i)+c(i)*a(i)+b(i)/a(i)+b(i)*a(i)+b(i);
end
t_parfor=toc(tstart)
Relevant answer
Answer
As far as I can see your variables are co-depent, so, when you call say c(i)=a(i)+b(i); it will wait until the previous lines are executed, since you use the value of c(i) there.
I suggest you make your variables more indepent, otherwise, sequential processing is the best solution.
  • asked a question related to C
Question
5 answers
How can I locate and distinguish between the N and C terminal in a Xray crystallographic structure of a protein in pdb?
Relevant answer
Answer
If you're looking at a protein molecule in a graphics programme like pymol, then the amino acid with the lowest residue number is the "visible" N-terminus and the one with the highest residue number is the "visible" C-terminus.
If you're looking at a pdb file instead, you'll see lines that look like this:
ATOM   1  N   LYS A 122      48.634 -28.081  21.272  1.00 44.28       N 
ATOM   2  CA  LYS A 122      47.475 -28.583  20.498  1.00 49.73       C 
ATOM   3  C   LYS A 122      46.238 -27.671  20.520  1.00 38.88       C 
ATOM   4  O   LYS A 122      45.871 -27.078  21.534  1.00 42.39       O 
ATOM   5  CB  LYS A 122      47.118 -29.995  20.929  1.00 55.26       C 
ATOM   6  CG  LYS A 122      46.105 -30.107  22.042  1.00 57.09       C 
ATOM   7  CD  LYS A 122      45.791 -31.570  22.263  1.00 66.89       C 
ATOM   8  CE  LYS A 122      44.770 -32.043  21.242  1.00 69.87       C 
ATOM   9  NZ  LYS A 122      44.677 -33.516  21.162  1.00 74.29       N 
I have highlighted the important bits by making them bold. If we concentrate on the second line: this means you're looking at atom number 2 in this pdb file, which is a carbon atom and belongs to a lysine residue, which is residue number 122 of chain A.
CA: this is the name of the atom. The atom type is mentioned at the end of the line (in this case it is C). As an amino acid has several atoms of the same type, they are given different names to distinguish them. For example CA, C, CB, CG, CD and CE are all carbon atoms and all have the identifier C at the end of the line, but they have different names after the atom number.
LYS: this is the name of the amino acid in three letter code that the atom belongs to (in this case lysine).
A: this is the name of the chain. There might be more than one molecule of the same protein in a crystal structure and therefore each protein molecule in a pdb file is generally given its own chain letter to distinguish between them.
122: this is the residue number allocated to the amino acid. This is the number you need to check. The amino acid with the lowest number will have the N-terminus. Remember that other atoms such as water molecules or ligand molecules that interact with a protein molecule are also included in the chain of that protein molecule. So make sure you are looking at an amino acid residue and don't just try to find the highest number in a chain, as that might belong to something else .
The amino acid with the highest residue number inside a chain will contain the C-terminus.
If you want to find the exact atom that forms the terminus rather than the whole residue, then look for the atom of type N with atom name N (as opposed to NZ, for example) in the N-terminal residue and the atom of type C with atom name C (as opposed to CA, CG, etc...) in the C-terminal residue.
Remember that often the residues at either terminus are disordered and therefore not visible in the crystal structure even though they are actually there. Hence, you need to distinguish between the "visible" termini and the "real" termini.
Also, sometimes the numbering can be a bit confusing. For example, very few proteins in crystal structures have "true" N- or C-termini that are identical to the corresponding sequence of the native protein deposited in a data bank. Because you need a lot of protein to make a protein crystal, the protein is generally expressed as recombinant protein with an affinity tag at either the N- or C-terminus. Even if the tag is removed before crystallisation, one or two extra amino acid residues remain that are not present in the native protein sequence. Therefore, you might have a structure that starts at residue -12 (e.g a protein with an N-terminal 6His-tag) or -2 (e.g where an N-terminal tag has been removed but two extra residues remain that are part of the recognition site needed by the protease used to remove the tag).
I hope this wasn't too confusing.
  • asked a question related to C
Question
4 answers
Theses days, I am doing literature review about the new trends in control of nonlinear systems, but it looks like this is a very broad subject. What are the new research areas in the control of such systems?
Relevant answer
Answer
Wang, T., Zhang, Y., Qiu, J., & Gao, H. (2015). Adaptive fuzzy backstepping control for a class of nonlinear systems with sampled and delayed measurements. Fuzzy Systems, IEEE Transactions on, 23(2), 302-312.
Liu, T., & Jiang, Z. P. (2015). Event-based control of nonlinear systems with partial state and output feedback. Automatica, 53, 10-22.
Chen, W., Sun, J., Chen, C., & Chen, J. (2015). Adaptive control of a class of nonlinear systems using multiple models with smooth controller. International Journal of Robust and Nonlinear Control, 25(6), 865-877.
Aranovskiy, S., Ortega, R., & Cisneros, R. (2015). Robust PI Passivity-based Control of Nonlinear Systems: Application to Port-Hamiltonian Systems and Temperature Regulation. arXiv preprint arXiv:1503.02935.
  • asked a question related to C
Question
5 answers
SupposeIi have a server program which is written in java, and the client program in C. How can I establish a communication link between them using TCP connection?
Relevant answer
Answer
One other method - JNI. One advantage of this is that you can call the java methods from C and vice-versa, however, the downside is JNI is more prone to Segmentation faults, and can crash your JVM. 
See JNI Documentation for more details.
  • asked a question related to C
Question
6 answers
Here are my codes:
if i want to do this addition 11+22 upon clicking on = button it should give me 33 but it does not work. the calculator must be able to perform addition correctly please help?
ActivityMain <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
tools:context=".MainActivity" />
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/editText1"
android:layout_marginTop="36dp"
android:text="1"
android:onClick="btn1Click"/>
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btn1"
android:layout_alignBottom="@+id/btn1"
android:layout_toRightOf="@+id/btn1"
android:text="2"
android:onClick="btn2Click" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btn2"
android:layout_alignBottom="@+id/btn2"
android:layout_toRightOf="@+id/btn2"
android:text="3"
android:onClick="btn3Click"/>
<Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btn1"
android:layout_marginTop="15dp"
android:text="4" />
<Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btn4"
android:layout_alignBottom="@+id/btn4"
android:layout_toRightOf="@+id/btn4"
android:text="5" />
<Button
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btn3"
android:layout_alignParentRight="true"
android:text="+"
android:onClick="btnAddClick"/>
<Button
android:id="@+id/btnSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btn5"
android:layout_alignParentRight="true"
android:text="-"
android:onClick="btnSubClick"/>
<Button
android:id="@+id/btnDiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:text="/" />
<Button
android:id="@+id/btnMul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/btnDiv"
android:layout_marginTop="14dp"
android:text="*" />
<Button
android:id="@+id/btnEqual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/btnMul"
android:layout_marginTop="15dp"
android:text="="
android:onClick="btnEq"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/editText1"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge" />
public class MainActivity extends Activity {
Button btn1;
Button btn2;
Button btn3;
Button btnAdd;
Button btnSub;
String btn_val1;
String btn_val2;
String btn_val3;
String btn_valAdd;
String btn_valSub;
EditText edit_text;
TextView textview;
int res;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void btn1Click(View view)
{
btn1 = (Button) findViewById(R.id.btn1);
btn_val1 = btn1.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview .append(btn_val1);
}
public void btn2Click(View view)
{
btn2 = (Button) findViewById(R.id.btn2);
btn_val2 = btn2.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview .append(btn_val2);
}
public void btn3Click(View view)
{
btn3 = (Button) findViewById(R.id.btn3);
btn_val3 = btn3.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview.append(btn_val3);
}
public void btnAddClick(View view)
{
btnAdd = (Button) findViewById(R.id.btnAdd);
//res = Integer.parseInt(btn_val1) + Integer.parseInt(btn_val2) + Integer.parseInt(btn_val3);
btn_valAdd = btnAdd.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview.append(btn_valAdd);
}
public void btnSubClick(View view)
{
btnSub = (Button) findViewById(R.id.btnSub);
//res = Integer.parseInt(btn_val1) - Integer.parseInt(btn_val2) - Integer.parseInt(btn_val3);
btn_valSub = btnSub.getText().toString();
textview = (TextView) findViewById(R.id.textView2);
textview.append(btn_valSub);
}
public void btnEq(View view)
{
textview = (TextView) findViewById(R.id.textView2);
if(btnAdd != null)
{
if(btn_val1 != null && btn_val2 != null )
{
res = Integer.parseInt(btn_val1) + Integer.parseInt(btn_val2);
textview.setText(String.valueOf(res));
}
else if(btn_val1 != null && btn_val3 != null)
{
res = Integer.parseInt(btn_val1) + Integer.parseInt(btn_val3);
textview.setText(String.valueOf(res));
}
else if(btn_val2 != null && btn_val3 != null)
{
res = Integer.parseInt(btn_val2) + Integer.parseInt(btn_val3);
textview.setText(String.valueOf(res));
}
else if(btn_val1 != null && btn_val2 != null && btn_val3 != null)
{
res = Integer.parseInt(btn_val1) + Integer.parseInt(btn_val2) + Integer.parseInt(btn_val3);
textview.setText(String.valueOf(res));
}
}
else if(btnSub != null)
{
res = Integer.parseInt(btn_val1) - Integer.parseInt(btn_val2) - Integer.parseInt(btn_val3);
textview.setText(String.valueOf(res));
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Relevant answer
Answer
Dear Nitish,
Here is a complete working code that I have written just for you I hope it helps you, and feel free to contact me if you need more help:
---------------------------------------------------------------------------------------------------
/** Author @Kelechi C Ofoleta*/
package com.kogonuso.calculator;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class Main extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText n1 = (EditText)findViewById(R.id.editText1);
EditText n2 = (EditText)findViewById(R.id.editText2);
TextView msg = (TextView)findViewById(R.id.msg);
try{
if((n1.getText().equals("")) || (n2.getText().equals(""))){
return;
}else{
double a = Double.valueOf(n1.getText().toString()).doubleValue();
double b = Double.parseDouble(n2.getText().toString());
double result = a+b;
msg.setText(result+"");
}
}catch(Exception e){
Toast bread = Toast.makeText(Main.this, "You must enter numbers to continue",Toast.LENGTH_LONG);
}
}
});
}
}
----------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Calculator</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="input1"></string>
<string name="input2"></string>
<string name="Number1">Number 1:</string>
<string name="Number2">Number 2:</string>
<string name="calc">Calc</string>
</resources>
------------------------------------------------------------------------------------------------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.kogonuso.calculator.Main" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Number1" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:text="@string/input1" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Number2" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:text="@string/input2" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/calc" />
<TextView
android:id="@+id/msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
---------------------------------------------------------------------------------