# Question:C codegen questions, errors, warnings and others

## Question:C codegen questions, errors, warnings and others

Maple
Hi all, I am having lots of trouble using C codegen in generating C code from Maple expressions. My questions are: 1. How to assume each element of a whole array or vector >0? Of course I can do: Assume (a[1]>0, a[2]>0, a[3]>0)... But I have "m" elements, how can I do that for all m elements? 2. What to do if the output says "the output length exceeds maximum limit of 1000000"? This occurred when I tried to "simplify" some complicated expression... obviously Maple did get some results, but it refused to print them out due to length limit, ... 3. There is no way to translate the result of "JJ16:=optimize(JJ15, 'tryhard')"? I found documentation says that 'tryhard' will give more performance improvement; but I just couldn't get the procedure optimized with "tryhard" option to be translated into C. Everytime I did that, it gives an empty translation result. 4. Warning: unable to determine array bounds in a[i]. For example, even for a simple expression "sum(a[k], k= 1 .. m)", the translator complains about not being able to determine the array bounds. 5. Real and Imaginary parts of a complex-valued function: Please recall my function is: t22 := (1/2*(a^2+2*sigma2*(c+g*(ee+i*v)))^(1/2)*exp(.5*a*t)/ (1/2*(a^2+2*sigma2*(c+g*(ee+i*v)))^(1/2)*cosh(1/2*(a^2+2*sigma2*(c +g*(ee+i*v)))^(1/2)*t)+.5*a*sinh(1/2*(a^2+2*sigma2*(c+g*(ee +i*v)))^(1/2)*t)))^(2*a*xbar/sigma2) My function outputs two-value array, let's say [y_re, y_im]=the_above_complicated_function(parameters), I separately did: y_re=evalc(Re(the_above_complicated_expression)); y_im=evalc(Im(the_above_complicated_expression)); and then combine them into an array output, of course there are many common factors in y_re and y_im, but even after combine them as array output, The C(%, optimized) translator doesnot generate good/efficient code, there are still lots of redundancy there. Is there a way to minimize the redundant overhead in computing y_re and y_im together, since I've combined them into an array output? There ought to be some approaches of doing common factor reduction in Maple... (I took such pain in extracting the real part and imaginary part of the complex-valued expression, because I want to avoid complex arithmetics in my C++ program. I estimated that the complex class will at least cost me 10x-20x more efficiency than real arithmetics.) Thanks a lot!
﻿