11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7.1 Code Generation • 291Many options can be used with the CodeGeneration functions. These aredescribed in detail on the ?CodeGenerationOptions help page. Some ofthe more commonly used ones are listed here.• optimize=value: This option specifies whether optimization is performed.The default value is false. When the value is true, thecodegen[optimize] function is used to optimize the Maple code beforeit is translated.• output=value: This option specifies the form of the output. By default,formatted output is printed to the terminal. If a name (differentfrom string) or a string is given as the value, the result is appendedto a file having that name. If the value is the name string, a stringcontaining the result is returned. This string may then be assignedand manipulated.• precision=value: This option specifies the precision used for floatingpointvariables and constants in the target language. Permissible valuesare single and double. The default value is double.Notes on Code Translation Because the Maple language differs substantiallyfrom the target languages supported by CodeGeneration, thetranslation capabilities are limited, and the generated output may notbe the exact equivalent of the input code. The ?CodeGenerationDetailshelp page provides more information on the translation process and hintson how to take full advantage of the facilities. In addition, there are helppages containing notes relevant to the specific languages:• ?CodeGeneration,CDetails• ?CodeGeneration,FortranDetails• ?CodeGeneration,JavaDetailsKey details are summarized in the following section.Translation ProcessThe CodeGeneration functions recognize only a subset of the Mapletypes. These are listed on the ?CodeGenerationDetails help page. TheMaple types are translated into appropriate types in the target language.Compatibility of types is checked before operations are translated, andtype coercions are performed where necesssary. The CodeGenerationfunctions attempt to deduce the types of any untyped variable. The usercan exercise greater control over type analysis and deduction, by using

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!