Items tagged with codegeneration codegeneration Tagged Items Feed



I am trying to create a Fortran routine that creates and populates a large 2D array, using Maple's codegen or CodeGeneration capabilities. I would like Maple to create the Fortran code so that the column-major ordering is respected: I would like Maple to populate mat(1,1), mat(2,1), mat(n,1) before moving on to mat(1,2)... Unfortunately, codegen and CodeGeneration seem to only produce row-major code.

Any idea on how to proceed, or an option of the code generation that I would have missed?


Thanks for your help!


I'm new to Maple, so my question could appear idiotic. But, anyway. :-)

I want to understand the restrictions of code generation in Maple.
What functions could I convert to code?
Only listed in "Translation of Functions" block in this link?

For example, I've found this post - 

Could functions "Maximize" and "diff" be converted to Java, VB or something or not? If yes, how?

Thanks anyway. :-)

Dear all,

I compute a 12,3 matrix in Maple and when I try to generate matlab code with optimization on, the result is a 36 element vector. Also, it warns me as "Warning, cannot resolve types, reassigning t15's type" and "Warning, cannot translate list". When I tried it without optimize=false it yields correct result but the file size is big. I have obtained the correct optimized resutls using Maple 13 before and hence i guess theres somthing to do with maple 17. Any...

Dear all

i am writing some differential equations with Maple. I'd like now to generate the Matlab code and let them run. Unfortunately I need the closed form but Maple does not distinguish (at first sight, of course) between time functions and parameters. But what in Maple is a time function, will be an array in Matlab. Unfortunately in Matlab environment the array product is carried out by the meaning of the element-by-element command: ".* " .

Using CodeGeneration[Matlab...

I have a Matrix 'A' in maple with symbolic entries and I need to use that Matrix in matlab M file. The symbols with in 'A' are already initialized in M file.

How is this possible?

For Matrices 'A' of small dimension, I can use the codegeneration package to convert 'A' to Matlab Matrix and then copy paste.

But for matrices of 1000x1000, lets say, does not seem as a option.


I need more help with code please!

A box of candy hearts contains 52 hearts, of which 19 are white, 10 are tan, 7 are pink, 3 are purple, 5 are yellow, 2 are orange, and 6 are green. If you select 9 pieces randomly without replacement, what is the probability that A_3 of the 9 are white, and B_3 of the 9 are white, 2 are tan 1 is pink and 1 is yellow and 2 are green

19 Whites in the pack / 52 hearts in the pack = .3654 possibility of picking a white from 1 draw.

How to convert Maple code to Matlab ?

comment je doiy faire pour convertir mon code Maple en Matlab?

merci d'avance pour votre aide.



How can i convert maple file to matlab ?

I want to extend the Maple CodeGeneration[C] by a handler for the piecewise function (no idea why it is not included).
To this end I did:

    LanguageDefinition:-Define("NewC", extend="C",
        AddFunction("piecewise", anything::numeric,


Can someone explain to me why when "x:=vector(2):" is used in the code below, the file "test_file.c" is generated correctly, while when "x := Vector(2,symbol=v):" is used, there is an error:

Error, (in codegen/makestat) symbol or symbol::type or symbol:=expression expected in parameter list


with(codegen, C, makeproc):

#x := Vector(2,symbol=v):

restart; with(plots); Eq1 := diff(f(eta), `$`(eta, 3))-(diff(f(eta), eta))^2+m*f(eta)*(diff(f(eta), `$`(eta, 2)))-(M^2+lambda*P)*(diff(f(eta), eta)) = 0; Eq2 := diff(theta(eta), `$`(eta, 2))+m*pr*f(eta)*(diff(theta(eta), eta))-lambda1*pr*theta(eta)*(diff(f(eta), eta)) = 0; bcs1 := f(0) = s, (D(f))(0) = -1, (D(f))(10) = 1; pr := .72; M := 1; m := 2; lambda := 1; lambda1 := 1; bcs2 := theta(10) = 0, theta(0) = 1; L := [0.5e-1, .1, .2, .4, .6, .8, 1, 5, 10, 20]; for k to 10 do R := dsolve...


I execue flow command,but it doesnot generate;

how i fix it?


> with(CodeGeneration);

> m:=diff(theta1(t),t);

> Matlab(m);

Warning, the function names {diff, theta1} are not recognized in the target language

cg0 = diff(theta1(t), t);

I am using the code generation package to generate fortran 90 code.   In a Maple module I have a procedure that uses "CodeGeneration[Fortran]" to turn a symbolic matrix into a subroutine in Fortran; i.e., given an n-vector q the Fortran subroutine will return an n by n matrix.  However, since Maple's "Fortran" command does not support Fortran 90 I have utilized the StringTools[RegSubs] to alter the line continuation differences between fortran 77 and fortran...

I keep getting this error although the code is running fine in maple 14 , Help is greatly appreciated Thanks alot

> restart; with(LinearAlgebra);
> A[0] := Vector(3, {(1) = 0, (2) = 0, (3) = -g});
> type(a[0], Vector);
> omega[0] := Vector(3, {(1) = 0, (2) = 0, (3) = 0});

I have a set of functions and parameters, I am computing Jacobian to those functions. I get a matrix rectangular in dimensions. So, determine Jacobian of sub-matrices(formed by removing one column for each sub-matrix) and equating them to zero.

> T := Matrix([[0], [4*t], [0]]); X := Matrix([[x1], [x2], [x3]]); R := Matrix([[1, 0, 0], [0, cos(pi*t), -sin(pi*t)], [0, sin(pi*t), cos(pi*t)]]);

> c1 := x1^2+x2^2-1/4-(1/4)*sin(l1); c2 := x3-sin(l2); c3 := t-1/2-(1/2)*sin(l3);>

1 2 Page 1 of 2