




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、RANDOM_NUMBERSyntax sintks n. 语法CALL RANDOM_NUMBER (harvest结果)Intrinsic Subroutine(固有子程序):Returns a pseudorandom number greater than or equal to zero and less than one from the uniform distribution.返回大于或等于0且小于1,服从均匀分布的随机数2、RNNOA/ DRNNOA (Single/Double precision)Generate pseudorandom numbers from a standard normal distribution using an acceptance/rejection method.产生服从标准正态分布的随机数Usage(用法)CALL RNNOA (NR, R)Arguments(参数)NR Number of random numbers to generate. (Input) 要产生随机数的个数R Vector of length NR containing the random standard normal deviates. (Output) 输出长度为NR,随机正态分布的向量Comments(注解)The routine RNSET can be used to initialize the seed of the random number generator. The routine RNOPT can be used to select the form of the generator.程序RNSET可以用来初始化随机数发生器的种子ExampleIn this example, RNNOA is used to generate five pseudorandom deviates from a standard normal distribution. INTEGER ISEED, NOUT, NR REAL R(5) EXTERNAL RNNOA, RNSET, UMACHC CALL UMACH (2, NOUT) NR = 5 ISEED = 123457 CALL RNSET (ISEED) CALL RNNOA (NR, R) WRITE (NOUT,99999) R99999 FORMAT ( Standard normal random deviates: , 5F8.4) END Output Standard normal random deviates: 2.0516 1.0833 0.0826 1.2777 -1.22603、RESHAPEIntrinsic Function(内部函数)Constructs an array of a specified shape from the elements of another array. 构造规定形式的数组Syntax(语法)result = RESHAPE (source, shape , pad , order ) source(Input) Any type. Array whose elements will be taken in standard Fortran array order (see Remarks), and then placed into a new array.shape(Input) Integer. One-dimensional array that describes the shape of the output array created from elements of source. 描述输出数组的大小的一维数组,The elements of shape are the sizes of the dimensions of the reshaped array in order. If pad is omitted省略, the total size specified by shape must be less than or equal to source.pad 可选参数(Optional; input) Same type as source. Must be an array. If there are not enough elements in source to fill the result array, elements of pad are added in standard Fortran array order. If necessary, extra copies of pad are used to fill the array. order 可选参数(Optional; input) Integer. One-dimensional array. Must be the same length as shape. Permutes the order of dimensions in the result array. The value of order must be a permutation of (1, 2,.n) where n is the size of shape.Return Value(返回值)The result is an array the same data type and kind as source and a shape as defined in shape. Examples INTEGER AR1( 2, 5)REAL F(5,3,8)REAL C(8,3,5)AR1 = RESHAPE(/1,2,3,4,5,6/),(/2,5/),(/0,0/),(/2,1/)! returns 1 2 3 4 5! 6 0 0 0 0! Change Fortran array order to C array orderC = RESHAPE(F, (/8,3,5/), ORDER = (/3, 2, 1/)END4、SUMIntrinsic Function(内部函数) Sums elements of an array or the elements along an optional dimension. The elements summed can be selected by an optional mask. 将数组中的元素求和Syntax(语法)result = SUM (array , dim , mask ) array(Input) Integer, real, or complex. Array whose elements are to be summed.dim 可选参数(Optional; input) Integer. Dimension along which elements are summed.1 dim n, where n is the number of dimensions in array.mask 可选参数(Optional; input) Logical. Must be same shape as array. If mask is specified, only elements in array that correspond to .TRUE. elements in mask are summed. Return Value(返回值)Same type and kind as array and equal to the sum of all elements in array or the sum of elements along dimension dim. If mask is specified, only elements that correspond to .TRUE. elements in mask are summed. Returns a scalar if dim is omitted or array is one-dimensional. Otherwise, returns an array one dimension smaller than array.Examples INTEGER array (2, 3), i, j(3)array = RESHAPE(/1, 2, 3, 4, 5, 6/), (/2, 3/)! array is 1 3 5 ! 2 4 6 i = SUM(/ 1, 2, 3 /) ! returns 6j = SUM(array, DIM = 1) ! returns 3 7 11WRITE(*,*) i, jEND5、SEEDRun-Time Subroutine Changes the starting point of the pseudorandom number generator. 改变随机数发生器的起始点ModuleUSE MSFLIB Syntax(语法)CALL SEED (iseed) iseed(Input) INTEGER(4). Starting point for RANDOM.Remarks(注解)SEED uses iseed to establish the starting point of the pseudorandom number generator. A given seed always produces the same sequence of values from RANDOM. If SEED is not called before the first call to RANDOM, RANDOM always begins with a seed value of one. If a program must have a different pseudorandom sequence each time it runs, pass the constant RND$TIMESEED (defined in MSFLIB.F90) to the SEED routine before the first call to RANDOM. Example USE MSFLIB REAL rand CALL SEED(7531) CALL RANDOM(rand)6、RANDOMPurposeRun-Time Subroutine Returns a pseudorandom number greater than or equal to zero and less than one from the uniform distribution. 返回大于或等于0且小于1,服从均匀分布的随机数ModuleUSE MSFLIB SyntaxCALL RANDOM (ranval) ranval(Output) REAL(4). Pseudorandom number, 0 ranval 1, from the uniform distribution.RemarksA given seed always produces the same sequence of values from RANDOM.If SEED is not called before the first call to RANDOM, RANDOM begins with a seed value of one. If a program must have a different pseudorandom sequence each time it runs, pass the constant RND$TIMESEED (defined in MSFLIB.F90) to SEED before the first call to RANDOM.All the random procedures (RANDOM, RAN, and RANDOM_NUMBER, and the PortLib functions DRAND, DRANDM, RAND, IRANDM, RAND, and RANDOM) use the same algorithms and thus return the same answers. They are all compatible and can be used interchangeably. (The algorithm used is a “Prime Modulus M Multiplicative Linear Congruential Generator,” a modified version of the random number generator by Park and Miller in “Random Number Generators: Good Ones Are Hard to Find,” CACM, October 1988, Vol. 31, No. 10.)CompatibilityCONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIBExample USE MSFLIB REAL(4) ran CALL SEED(1995) CALL RANDOM(ran)7、FFT2BCompute the inverse Fourier transform of a complex periodic two-dimensional array.计算二维复数数组的逆傅里叶变换Usage(用法)CALL FFT2B (NRCOEF, NCCOEF, COEF, LDCOEF, A, LDA)Arguments(参数)NRCOEF The number of rows of COEF. (Input) 数组COEF的行数NCCOEF The number of columns of COEF. (Input) 数组COEF的列数COEF NRCOEF by NCCOEF complex array containing the Fourier coefficients to be transformed. (Input) NRCOEF行NCCOEF列数组LDCOEF Leading dimension of COEF exactly as specified in the dimension statement of the calling program. (Input)A NRCOEF by NCCOEF complex array containing the Inverse Fourier coefficients of COEF. (Output) NRCOEF行NCCOEF列复数数组,包含数组COEF的逆傅里叶系数LDA Leading dimension of A exactly as specified in the dimension statement of the calling program. (Input)Comments(注解)1.Automatic workspace usage isFFT2B4 * (NRCOEF + NCCOEF) + 32 + 2 * MAX(NRCOEF, NCCOEF) units, orDFFT2B8 * (NRCOEF + NCCOEF ) + 64 + 4 * MAX(NRCOEF, NCCOEF) units.Workspace may be explicitly provided, if desired, by use of F2T2B/DF2T2B. The reference isCALL F2T2B (NRCOEF, NCCOEF, A, LDA, COEF, LDCOEF, WFF1, WFF2, CWK, CPY)The additional arguments are as follows:WFF1 Real array of length 4 * NRCOEF + 15 initialized by FFTCI. The initialization depends on NRCOEF. (Input)WFF2 Real array of length 4 * NCCOEF + 15 initialized by FFTCI. The initialization depends on NCCOEF. (Input)CWK Complex array of length 1. (Workspace)CPY Real array of length 2 * MAX(NRCOEF, NCCOEF). (Workspace)2.The routine FFT2B is most efficient when NRCOEF and NCCOEF are the product of small primes.3.The arrays COEF and A may be the same.4.If FFT2D/FFT2B is used repeatedly, with the same values for NRCOEF and NCCOEF, then use FFTCI to fill WFF1(N = NRCOEF) and WFF2(N = NCCOEF). Follow this with repeated calls to F2T2D/F2T2B. This is more efficient than repeated calls to FFT2D/FFT2B.AlgorithmThe routine FFT2B computes the inverse discrete complex Fourier transform of a complex two-dimensional array of size (NRCOEF = N) (NCCOEF = M). The method used is a variant of the Cooley-Tukey algorithm , which is most efficient when N and M are both products of small prime factors. If N and M satisfy this condition, then the computational effort is proportional to N M log N M. This considerable savings has historically led people to refer to this algorithm as the fast Fourier transform or FFT.Specifically, given an N M array c = COEF, FFT2B returns in aFurthermore, a vector of Euclidean norm S is mapped into a vector of normFinally, note that an unnormalized inverse is implemented in FFT2D. The routine FFT2B is based on the complex FFT in FFTPACK. The package FFTPACK was developed by Paul Swarztrauber at the National Center for Atmospheric Research.ExampleIn this example, we first compute the Fourier transform of the 5 4 arrayfor 1 n 5 and 1 m 4 using the IMSL routine FFT2D. The resultis then inverted by a call to FFT2B. Note that the result is an array a satisfying a = (5)(4)x = 20x. In general, FFT2B is an unnormalized inverse with expansion factor N M. INTEGER LDA, LDCOEF, M, N, NCA, NRA COMPLEX CMPLX, X(5,4), A(5,4), COEF(5,4) CHARACTER TITLE1*26, TITLE2*26, TITLE3*26 INTRINSIC CMPLX EXTERNAL FFT2B, FFT2D, WRCRNC TITLE1 = The input matrix is below TITLE2 = After FFT2D TITLE3 = After FFT2B NRA = 5 NCA = 4 LDA = 5 LDCOEF = 5C Fill X with initial data DO 20 N=1, NRA DO 10 M=1, NCA X(N,M) = CMPLX(FLOAT(N+5*M-5),0.0) 10 CONTINUE 20 CONTINUEC CALL WRCRN (TITLE1, NRA, NCA, X, LDA, 0)C CALL FFT2D (NRA, NCA, X, LDA, COEF, LDCOEF)C CALL WRCRN (TITLE2, NRA, NCA, COEF, LDCOEF, 0)C CALL FFT2B (NRA, NCA, COEF, LDCOEF, A, LDA)C CALL WRCRN (TITLE3, NRA, NCA, A, LDA, 0)C END Output The input matrix is below 1 2 3 41 ( 1.00, 0.00) ( 6.00, 0.00) ( 11.00, 0.00) ( 16.00, 0.00)2 ( 2.00, 0.00) ( 7.00, 0.00) ( 12.00, 0.00) ( 17.00, 0.00)3 ( 3.00, 0.00) ( 8.00, 0.00) ( 13.00, 0.00) ( 18.00, 0.00)4 ( 4.00, 0.00) ( 9.00, 0.00) ( 14.00, 0.00) ( 19.00, 0.00)5 ( 5.00, 0.00) ( 10.00, 0.00) ( 15.00, 0.00) ( 20.00, 0.00) After FFT2D 1 2 3 41 ( 210.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年特岗教师招聘考试初中生物模拟题及答案
- 2025年网络安全工程师职位面试预测题与解析
- 【教案版】小学二班级上册 轮滑
- 2025年炼油装置中级操作工面试技巧与模拟试题
- 2025年教育培训专员面试技巧与模拟题集
- 2025年中级会计师职称考试试题集与解析
- 2025年权威资料特岗教师招聘初中地理全真模拟题及答案收录
- 2025年生物科技行业招聘面试预测题集萃
- 2025年烷基化工艺作业面试常见问题解答
- 2025年电气工程师初级面试预测题及专业知识点梳理
- 1.1 鸦片战争 课件 2024-2025学年统编版八年级历史上册
- 2024至2030年中国演播室行业市场调查研究及发展战略规划报告
- DB11∕T 420-2019 电梯安装、改造、重大修理和维护保养自检规则
- 国旗台施工合同
- 如何申请非遗
- 总代理授权书
- 越剧《梁山伯与祝英台》剧本
- 广东省广州市越秀区2024年八年级下学期期末英语试卷附答案
- 医疗器械售后服务能力证明资料模板
- (正式版)JBT 14449-2024 起重机械焊接工艺评定
- (正式版)HGT 4144-2024 工业用二正丁胺
评论
0/150
提交评论