Maple & MapleSim分享 http://blog.sciencenet.cn/u/maplesim

留言板

facelist

您需要登录后才可以留言 登录 | 注册


IP: 218.201.115.*   [12]李刚   2015-7-27 15:42
请问如何在苹果电脑上安装Maple.谢谢!
IP: 112.64.157.*   [11]hanmoyuan   2015-4-2 13:27
电动汽车的锂离子电池的热模型如何建?
IP: 222.175.103.*   [10]Hayekqiao   2014-11-28 13:56
徐老师您好,我是山东大学物理学院的学生。在用maple做一点计算的时候遇到一点问题,希望得到徐老师的指点。谢谢。
maple中用leastsqrs命令求解线性方程组的近似解,如果对解的取值范围有要求,比如大于零,能用leastsqrs来实现吗?类似的regression命令中的LinearFit也是一样,是否可以通过设置output options来实现呢?我试了几次都没有成功,所以来寻找徐老师的帮助,谢谢。
IP: 210.75.233.*   [9]fairfanfan   2014-5-26 11:11
老师,您好!
您有用openmaple在c++中调用maple的函数进行符号矩阵运算的例子吗?如inverse(),transpose()等。
谢谢!
我的回复(2014-5-27 09:19):Here is a very simple C program showing how to connect to Maple and call a basic Maple command.  The program calls Maple's diff routine via the OpenMaple API to compute the derivative of
                          sin(cos(x))
symbolically and evaluate it at
                             x = 3
.

     #include <stdio.h>
    #include <stdlib.h>

    /* OpenMaple routines are defined here */
    #include "maplec.h"
   
    /* Callback used for directing result output */
    static void M_DECL textCallBack( void *data, int tag, char *output )
    {
        printf("%s\n", output);
    }
      
    int main( int argc, char *argv[] )
    {
        char err[2048];

        /*
         * Maple kernel vector - used to start and make calls to Maple.
         * All OpenMaple function calls take kv as an argument.
         */
        MKernelVector kv;  
        MCallBackVectorDesc cb = {  textCallBack,
                                    0,   /* errorCallBack not used */
                                    0,   /* statusCallBack not used */
                                    0,   /* readLineCallBack not used */
                                    0,   /* redirectCallBack not used */
                                    0,   /* streamCallBack not used */
                                    0,   /* queryInterrupt not used */
                                    0    /* callBackCallBack not used */
                                 };

        /*
         * ALGEB is the C data type for representing Maple
         * data structures
         */
        ALGEB r, l;  
   
        /* Initialize Maple  */
        if( ( kv = StartMaple(argc, argv, &cb, NULL, NULL, err) ) == NULL ) {
            printf( "Could not start Maple, %s\n", err );
            return( 1 );
        } else {
            printf( "Maple started\n" );
        }
  
        /*
         * Compute the derivative of sin(cos(x)).
         * Output goes through the textCallBack() procedure.
         */
        printf( "Compute a derivative: \n\t" );
        r = EvalMapleStatement( kv, "diff(sin(cos(x)),x);" );
   
        /* Evaluate the derivative at x = 3 */
        MapleAssign(kv,
                    ToMapleName( kv, "x", TRUE ),
                    ToMapleInteger( kv, 3 ));
        r = MapleEval( kv, r );
        MapleALGEB_Printf( kv, "\nThe derivative at x=3 is: %a\n", r );
   
        return( 0 );
    }
Compile := proc(src::string, dll::string)
    local mpldir, cmpcmd, lnkcmd, res;

    mpldir := "C:\\PROGRA~1\\MAPLE1~1";
   
    cmpcmd := sprintf("wcl386 -c -D_MSC_VER %s.c -fo=%s.obj", src, src);
    lnkcmd := sprintf("wlink system nt_win libpath %s\\bin.win library maplec.lib file %s name %s", mpldir, src, dll):
   
    res := ssystem(cmpcmd);
    printf("%s\n", res[2]);
    res := ssystem(lnkcmd);
    printf("%s\n", res[2]);

    NULL;

end proc:
C_OPEN_MAPLE_EXE := "COpenMaple.exe";
C_OPEN_MAPLE_SRC := "COpenMaple";
Compile(C_OPEN_MAPLE_SRC, C_OPEN_MAPLE_EXE);
res := ssystem("COpenMaple"):
printf("%s", res[2]);
我的回复(2014-5-27 09:18):Here is a very simple C program showing how to connect to Maple and call a basic Maple command.  The program calls Maple's diff routine via the OpenMaple API to compute the derivative of
                          sin(cos(x))
symbolically and evaluate it at
                             x = 3
.

     #include <stdio.h>
    #include <stdlib.h>

    /* OpenMaple routines are defined here */
    #include "maplec.h"
   
    /* Callback used for directing result output */
    static void M_DECL textCallBack( void *data, int tag, char *output )
    {
        printf("%s\n", output);
    }
      
    int main( int argc, char *argv[] )
    {
        char err[2048];

        /*
         * Maple kernel vector - used to start and make calls to Maple.
         * All OpenMaple function calls take kv as an argument.
         */
        MKernelVector kv;  
        MCallBackVectorDesc cb = {  textCallBack,
                                    0,   /* errorCallBack not used */
                                    0,   /* statusCallBack not used */
                                    0,   /* readLineCallBack not used */
                                    0,   /* redirectCallBack not used */
                                    0,   /* streamCallBack not used */
                                    0,   /* queryInterrupt not used */
                                    0    /* callBackCallBack not used */
                                 };

        /*
         * ALGEB is the C data type for representing Maple
         * data structures
         */
        ALGEB r, l;  
   
        /* Initialize Maple  */
        if( ( kv = StartMaple(argc, argv, &cb, NULL, NULL, err) ) == NULL ) {
            printf( "Could not start Maple, %s\n", err );
            return( 1 );
        } else {
            printf( "Maple started\n" );
        }
  
        /*
         * Compute the derivative of sin(cos(x)).
         * Output goes through the textCallBack() procedure.
         */
        printf( "Compute a derivative: \n\t" );
        r = EvalMapleStatement( kv, "diff(sin(cos(x)),x);" );
   
        /* Evaluate the derivative at x = 3 */
        MapleAssign(kv,
                    ToMapleName( kv, "x", TRUE ),
                    ToMapleInteger( kv, 3 ));
        r = MapleEval( kv, r );
        MapleALGEB_Printf( kv, "\nThe derivative at x=3 is: %a\n", r );
   
        return( 0 );
    }
Compile := proc(src::string, dll::string)
    local mpldir, cmpcmd, lnkcmd, res;

    mpldir := "C:\\PROGRA~1\\MAPLE1~1";
   
    cmpcmd := sprintf("wcl386 -c -D_MSC_VER %s.c -fo=%s.obj", src, src);
    lnkcmd := sprintf("wlink system nt_win libpath %s\\bin.win library maplec.lib file %s name %s", mpldir, src, dll):
   
    res := ssystem(cmpcmd);
    printf("%s\n", res[2]);
    res := ssystem(lnkcmd);
    printf("%s\n", res[2]);

    NULL;

end proc:
C_OPEN_MAPLE_EXE := "COpenMaple.exe";
C_OPEN_MAPLE_SRC := "COpenMaple";
Compile(C_OPEN_MAPLE_SRC, C_OPEN_MAPLE_EXE);
res := ssystem("COpenMaple"):
printf("%s", res[2]);
IP: 114.255.218.*   [8]袁正中   2013-12-25 20:00
老师,您好。想问一下maple怎么做线性系统的可控性判定、可控分解等线性系统的一些问题,或者有没有书籍介绍这个方面的maple使用啊?谢谢
我的回复(2014-2-7 10:25):可借鉴的资料:
http://maplesoft.com/applications/Category.aspx?cid=193

FAQ:
http://www.mapleprimes.com/
IP: 60.183.48.*   [7]sctmxhu   2012-10-15 22:14
徐老师,好!不知道,物理包中,对于两个对易算符,如何确定输出中,某一算符在另一算符的右侧或左侧。这样,对于简化式子还是很有帮助的。
IP: 139.226.23.*   [6]夏铁成   2012-9-7 16:44
祝徐老师工作愉快!
IP: 219.223.244.*   [5]mdscll   2012-8-22 14:29
请问一下,Maplesim建立的物理模型转成C代码时,Solver中只有Euler,RK2,RK3,RK4这四种方法,但我的模型涉及刚性方程,需要用rosenbrock,怎么弄呢?
IP: 218.76.140.*   [4]罗再磊   2012-7-4 13:25
   以后多向博主学习
IP: 222.88.196.*   [3]李志强   2012-3-30 17:54
博主也在用maple?
我的回复(2012-4-5 14:49):原厂Maplesoft,力学所毕业的,戴老师课题组的人都知道。
IP: 58.198.107.*   [2]shuishousong   2011-1-14 21:26
刚开门,来踹一脚!!
我的回复(2011-1-31 16:57):   恭喜发财!
IP: .*   [1]科学网编辑部   2010-12-14 12:38
欢迎您入住科学网!如果您有任何疑问,请参考博客首页上端的博客帮助,如果还不能回答您的疑问,请与博客管理员联系:blog@stimes.cn。祝您开博愉快!

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-3-28 18:01

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部