Mathematica基础及其高级应用.ppt_第1页
Mathematica基础及其高级应用.ppt_第2页
Mathematica基础及其高级应用.ppt_第3页
Mathematica基础及其高级应用.ppt_第4页
Mathematica基础及其高级应用.ppt_第5页
已阅读5页,还剩54页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、字符串相关,字符和字符串,字符串用双引号括起”字符串”,InputFormexp返回Mathematica输入形式 OutputFormexp返回Mathematica输出形式 StandardFormexp返回标准二维表达式 FullFormexp返回全形式 Compressexp和Uncompressexp压缩 Styleexp, 颜色字体等等改变输出的样式,字符串运算,s1s2或StringJoins1,s2,字符串连接 StringLengths字符串的长度 StringReverses颠倒字符串的顺序,子串操作,StringTakes, ns的前n个字符 StringTakes, n

2、s的第n个字符 StringTakes, n1, n2 s的n1到n2子串 StringDrops, n截掉前n个字符 StringDrops, n1, n2截掉n1到n2个字符 StringInserts, subs, n在位置n插入子串 StringInserts, subs, n1, n2,多次插入子串,替换操作,StringReplaceParts, subs, m, n用新串替换m到n的部分 StringReplaceParts, subs, m1, n1, m2, n2, 多次替换 StringReplaceParts, subs1, subs2, m1, n1, m2, n2,多

3、次按照相应新串替换,找出子串位置,StringPositions, subs给出子串位置(返回起始和结束位置的列表) StringPositions, subs, k仅给出前k次出现的位置 StringPositions, sbus1, subs2, 给出多个子串中任意一个出现的位置,这些函数都支持IgnoreCase-True参数,字符串表达式s1s2或者StringExpressions1,s2,“ab”_表示”ab”后面跟随单个字符 x_x_表示成对字符 _表示跟随零个或更多字符,按照规则替换,StringReplaces, s1-sp1, s2-sp2,字符串模式,string1=st

4、ring2测试字符串是否相等 StringMatchQs, pattern测试字符串是否与模式匹配 模式中常用替代字符 *任意个字符,原来的*用* 非大写的一个或多个字符,字符串中的字符,Characterss将字符串转化为字符列表,和字符有关的函数,DigitQs字符串是否为数字 LetterQs字符串所有字符是否为字母 UpperCases 字符串所有字符是否为大写字母 LowerCaseQs字符串所有字母是否为小写字母 ToUpperCases ToLowerCases CharacterRange“c1”, “c2”产生从c1到c2的字符表,特殊字符,Mathematica字符串支持特

5、殊字符 name使用全名的字符,如Alpha, LongRightArrow ”和使用”和 n换行 “”字符串中换行用n替代 tTab符,字符代码,ToCharacterCodes给出代码列表 FromCharacterCoden1, n2, n3,从代码生成字符串,字符代码直接输入的方式,.nn十六进制nn对应的字符 :nnnn十六进制nnnn对应的字符 例如:”.41.e0:03b1:2135”,字符的编码,$CharacterEncoding= “name”设置编码 $CharacterEncodings给出所有编码 ToCharacterCode, FromCharacterCode,

6、 ToString等函数都可以通过CharacterEncoding-”name”指定编码,要求输入,Input“提示信息”,默认值 InputString“提示信息”, “默认值”,表达式的翻译,ToStringexpr, form ToBoxesexpr, form ToExpressioninput, form从字符串或盒子转化为表达式 其中参数可为StandardForm, TraditionalForm, InputForm等等,缩短输出,Shortexpr用一行显示expr轮廓 Shortexpr, n用n行显示expr轮廓 Shallowexpr显示expr的顶层 Shallow

7、expr, depth, length指定显示的深度和长度 Skeletonn即为(仅见于输出),面向字符串的输出格式,StringForm“controlstring”,expr1,把控制字符串内中的内容用后面的表达式替代,一系列表达式的输出,SequenceFormexpr1, expr2, ,表达式输出,ColumnFormexpr1, expr2, 左对齐的列 ColumnFormlist, h, v指定对齐方式 h可取Left, Center, Right v可取Below, Center, Above,不计算表达式的输出,HoldFormexpr,数字的输出格式,Scientifi

8、cFormexpr科学计数法 EngineeringFormexpr工程计数法 AccountingFormexpr标准会计计数法,控制数字的显示,NumberFormexpr, tot输出tot位有效数字,PaddedFormexpr, tot数字用tot位表示,不足时前面加空格补齐 BaseFormexpr, b用b进制表示,StyleFormexpr, options用指定的格式显示,格式可选项FontSize(12), FontWeigth(“Plain”或”Bold”), FontSlant(“Plain”或”Italic”), FontFamily(“Courier”, “Time

9、s”, “Helvetica”,), FontColor, BackGround 利用StyleBox和DisplayForm也能实现同样的功能,MathLink和外部程序通讯,MathLink和外部程序通讯,在Mathematica中调用外部程序中的函数 外部程序调用Mathematica 对Mathematica设置不同的前端 在Mathematica和外部程序之间交换数据 Mathematica过程中交换数据,安装已有的与MathLink兼容的程序,link=Install“prog” 象使用普通函数一样使用prog中的函数 Unistalllink Links“prog”显示与prog

10、有关的激活链接 LinkPatternslink显示链接中可计算的模式,MathLink模板文件 f.tm,:Begin: :Function:f :Pattern:MyAddx_Integer, y_Integer :Arguments:x, y :ArgumentTypes:Integer, Integer :ReturnType:Integer :End:,:Evaluate: 后面的语句只在安装外部函数时运行,例如 :Evaluate: MyAdd:usage=“MyAdd performs my addition in an external program.”,C语言文件 f.c,

11、#include “mathlink.h” int f(int x, int y) return x+y; int main(int argc, char *argv) return MLMain(argc, argv); ,处理源文件,mcc预处理和编译源文件 mprep预处理源文件 例如:mcc o f.exe f.tm f.c,外部程序也可调用Mathematica命令,MLEvaluateString(stdlink, “string”) 例如 int diff(int i, int j) if(ij) MLEvaluateString(stdlink, “Print”negative

12、”); return i-j; ,此调用所产生的结果将被忽略!,基本类型对应关系,向Mathematica传递数据,MLPutInteger(stdlink, int i) MLPutReal(stdlink, double x) MLPutIntegerList(stdlink, int * a, long n) MLPutRealList(stdlink, double * a, long n) MLPutIntegeArray(stdlink, int *a, long * dims, NULL, long d) MLPutRealArray(stdlink, double *a, lo

13、ng * dims, NULL, long d) MLPutString(stdlink, char *s) MLPutSymbol(stdlink, char *s) MLPutFunction(stdlink, char*s, long n),从Mathematica获得数据,MLGetInteger(stdlink, int*), MLGetReal MLGetIntegerList(stdlink ,int * a, long * n), MLGetRealList MLGetIntegerArray, MLGetRealArray, MLGetString, MLGetSymbol

14、另有相对应的MLDisownIntegerList(stdlink, int *, long n)等用来释放内存 MLCheckFunction(stdlink, “name”, long *n)检查函数的变量数目,Mathematica进程间的通讯,Link=LinkCreate“name” Name可以是另外的程序,也可是端口号 “numberhost” or “number”,参数如LinkProtocol-”TCPIP” LinkConnect“name”与LinkCreate类似 LinkCloselink关闭通讯,Mathematica进程间的通讯,LinkWritelink, e

15、xpr LinkReadlink LinkReadyQlink查询状态 Unevaluatedexpr可以阻止write方计算表达式 LinkReadlink可加参数Hold LinkInterruptlink发送一个中断,MathLink连接到辅助程序上,LinkLaunch“prog”,区分同一个外部程序不同线程的函数名,在模板文件中 :Pattern:函数第一个参数$CurrentLink,后面写函数本身的参数 调用时 FunNamelink, argus,从外部程序中运行Mathematica,MLENV env = MLInitialize(char *) 0) MLINK link

16、 = MLOpenArgv(env, char* string, long * errno) or (env, int argc, char* argv, long *errno) Int MLActivate(link)激活链接 Void MLClose(link) MLDeinitialize(env),Mathematica全局观,$Input $Output $Echo $Urgent $Message $Display $SoundDisplay Streams or Streams“name”,对话,Dialog启动对话 Dialogexpr启动对话并把expr作为%的当前值 Re

17、turn从对话返回,并把%作为返回值 Returnexpr返回expr值,日期和时间,Date or Date时区 TimeZone AbsoluteTime从1900.1.1起总秒数 SessionTime TimeUsed, Timingexpr Pause秒数 FromDatedate和ToDatetime TimeConstrainedexpr, t限时计算,内存管理,MemoryInUse MaxMemoryUsed MemoryConstrainedexpr, b ByteCountexpr Shareexpr优化存储,其他全局变量,$CommandLine $ProcessID $UserName $SessionID $Version $System .,级数相关,级数复合运算ComposeSeriesser1, ser2, 级数反演InverseSeriesseries, x 级数的系数SeriesCoefficientseries, n LogicalExpandseries1=series2给出系数相等的方程 Solveseries1=series2,a1, a2, 求幂级数的系数,用户界面相关,Buttonlabel, action DefaultButton, CancelButton, PasteButton

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论