资源说明:A spectral and high-order methods collection of routines for Matlab. Requres both my setuplab and labtools repos.
________________________________________________________________________________ Speclab: A spectral/high-order methods package for Matlab Copyright (c) 2009 Akil Narayan Version 0.5 ________________________________________________________________________________ Contents: 1.) License 2.) Features 3.) Setup (PLEASE READ) 4.) Intended audience 5.) Validation tests (optional) 6.) Coding conventions 7.) Examples (PLEASE READ) 8.) Development history 9.) TODO's 10.) Contact ________________________________________________________________________________ 1.) License ________________________________________________________________________________ Speclab is released under the MIT License. See the LICENSE file in this directory. Basically do what you want, and don't sue me. And give me credit if any is due. ________________________________________________________________________________ 2.) Features ________________________________________________________________________________ Version 0.5 of Speclab provides the following functionality: - User-prescribed affine scaling - Automatic affine scaling based on user-desired resolution requirements - Jacobi polynomials (Chebyshev, Legendre, Gegenbauer inclusive) - evaluation of L^2-normalized and monic polynomials and derivatives of any order - Gauss(-Radau/Lobatto) quadrature - Jacobi-Jacobi connection operators between certain classes - FFT algorithms for certain classes of Jacobi polynomials - O(N) differentiation in modal space via connection coefficients/three-term recurrences - (Generalized) Fourier series - evaluation of L^2-normalized functions and first derivatives - Gauss quadrature - Fourier-Fourier connections between certain classes - FFT algorithms for certain classes - Generalized Wiener rational functions - evaluation of L^2 normalized functions and first derivatives - Gauss-type quadrature - FFT 'collocation' and 'Galerkin' algorithms for certain classes - stiffness matrix computations ________________________________________________________________________________ 3.) Setup ________________________________________________________________________________ Speclab should work under Matlab version >= 7.6 (R2008a). And although I haven't explicitly tested it, I see no reason why it wouldn't work with versions earlier than that as well. (There is an exception for running the optional validation tests, see section 5.) Speclab does *not* work out of the box. You have to run one function beforehand, aptly named 'setup.m'. This file is located in the base directory of the Speclab bundle. You can just cd into the directory in Matlab, and run >> setup; Depending on what your directory structure is set up like, setup might make some comments about ignoring directories. Setup should terminate with some nice-sounding message(s) about successfully doing things. Speclab is now set up and ready for use. In the course of your computations, if you ever run 'clear all' or 'clear global' then *you will have to run setup again*. PLEASE READ THE EXAMPLES SECTION IN THIS FILE BEFORE PROCEEDING TO USE SPECLAB. Optional reading: setup.m does two things: 1.) Creates a Matlab-global variable called 'packages'. packages is a nested struct whose tree-like structure mimics Speclab's directory structure. Each node of the tree corresponds to an m-file function inside Speclab. In this way, functions in e.g. the Fourier side of Speclab can access functions in the Jacobi polynomial section of Speclab without needing to do messy things like changing directories or adding a bunch of directories to Matlab's PATH variable, thereby polluting the command line namespace. As mentioned before, if you happen to clear this global variable, you'll have to run setup.m again to rewrite it. You can inspect packages yourself by typing >> global packages at the command line. And then inspecting the variable. 2.) Regrettably...adds some directories to Matlab's PATH variable. However, the only directories it adds are those associated with class declarations. Function names are not introduced into the global path at all, only class names. Class names are declared in the FirstLetterUppercase format. Functions are declared in the all_lowercase_underscore_separation format. This rubric is (hopefully) consistent across Speclab. ________________________________________________________________________________ 4.) Intended audience ________________________________________________________________________________ Speclab is intended for those familiar with spectral expansions of various types. It can also be used by those who are in the process of learning about spectral approximations from a different source. It is meant to be a tool used for quick implementation to test something out, or a sandbox to try out some ideas. If you want a primer on high-order methods, look elsewhere. Speclab is NOT meant to - have commercial-grade speed. The entire package is written in Matlab and has limited speed for that reason. - be super fast even in Matlab. It is written with the intention of being fast for most applications, but the emphasis is on giving routines license to do very general things while keeping the code simple, easy to read, and modularized. - be a tutorial for those wholly unfamiliar with spectral expansions If you're interested in having a robust tool for doing spectral calculations in Matlab that prizes generality and usability over speed, then you may be interested in Speclab. ________________________________________________________________________________ 5.) Validation Tests ________________________________________________________________________________ Once setup.m is run, Speclab is ready to go. However, for peace of mind, it might be beneficial to run the Speclab validation tests. Running these tests can take up to 5 minutes, but generally only take 2 minutes or so. >> setup; >> global packages >> packages.speclab.debug.all_tests(); This runs a bunch (~400) of tests with some relatively well-formatted output. The test parameters are randomized, so it's not a big deal if a dozen or so of the tests fail. I haven't gotten around to tweaking the randomness to ensure success. NOTE: As of this writing, Speclab does *not* require class/object-oriented support in Matlab to work. (That will change in the future.) However, running the validation tests *does* require classes. The validation tests should run with Matlab version >= 7.6 (R2008a). For lower versions, Matlab will probably return a slew of errors. ________________________________________________________________________________ 6.) Coding conventions ________________________________________________________________________________ Throughout Speclab, the following coding conventions are used. All function names use the lowercase_verbose_underscore_separated_naming convention. This does not relieve one from typing a long name, but does remove the problem of figuring out what onemrsqxp.m does. Instead, it will say one_minus_r_squared_times_p.m, which is much easier to figure out. Classes are not yet (really) built into Speclab yet. When they are, class names will use the AllUppercaseNoSpacing format. Again, not necessarily short, but effective at getting the point across and differentiating from function names. Each m-file has a (hopefully) descriptive helpstring. In Matlab, you can cd into the directory containing file.m and type "help file" and it will print the helpstring. However, functions in Speclab are usually called via a function handle and not by changing directories (see the Setup section). Matlab's help function does not recognize what to do with function packages, so unfortunately you have to take the roundabout way of getting help: If you want help for the function with handle packages.speclab.fourier.affine_scaling, you can type at the command line: >> packages.helper('speclab', 'fourier', 'affine_scaling') I.e., just use the same tree structure split into strings as multiple inputs into the function packages.helper. Most m-files take optional arguments. Rather than deal with things like "if nargin<=5 elseif nargin>3..." I've decided to use something akin to Matlab's InputParser. However, the way InputParser works is not very transparent to me, and it's new enough that I feel like Mathworks might change conventions on me. Therefore, I've written packages.labtools.input_schema, which does two things: - conspicuously breaks the aforementioned convention that function_names will have a certain format :( (on a TODO list for a future release) - essentially does the same thing as InputParser but works very transparently with structs. input_schema packages almost all optional input arguments in Speclab. (There are some exceptions when I avoid calling input_schema because it saves a bit of run-time.) In helpstrings, optional inputs are given in curly {} brackets. See speclab/examples/chebyshev/intro.m on how to call functions with optional arguments. There are some files strewn about Speclab that are named something like function_name_.m. Notice the extra underscore "_" before the extension .m. This underscore at the end denotes that this is a deprecated/in-progress file and you should not rely on it; I haven't tested such files at all. ________________________________________________________________________________ 7.) Examples ________________________________________________________________________________ All examples are contained in the speclab/examples folder. All examples are script m-files with code and comments to describe what is going on. You should be able to jump to whatever expansion you care about and start running those examples. However, it is *highly recommended* that you go through the Chebyshev examples first (speclab/examples/chebyshev). The Chebyshev example files contain comments that describe the gist of how to run things in Speclab including helpstring format, parameter inputs, general structure of a spectral expansion. The other expansion examples do not go into such wordy detail in the comments and assume you know how to do basic things in Speclab. Other README files in the examples folder with some not-so-detailed specifics about expansions: -- speclab/examples/chebyshev/README -- speclab/examples/legendre/README -- speclab/examples/jacobi/README -- speclab/examples/fourier/README -- speclab/examples/wiener/README ________________________________________________________________________________ 8.) Development history ________________________________________________________________________________ If you'd like the whole development history for Speclab, you'll need the open-source "distributed version control system" called "git". Once you have git installed. Open up a command line, and do the following: 1.) Decide what directory you'd like to install this stuff in. For this example, I'll call this directory mfiles. 2.) Run "git clone git://github.com/cygnine/CommonMatlab.git mfiles" 3.) Run "cd mfiles" 4.) Run "git clone git://github.com/cygnine/speclab.git" There are two git repositories: the "CommonMatlab" one packages all things not related to (but used by) Speclab. Speclab has it's own git repository and history. You may navigate a web browser to - http://www.github.com/cygnine/CommonMatlab - http://www.github.com/cygnine/speclab and github will show a pretty GUI of the development history and included files. You can also download a tarball directly from github of each repo, but the tarball won't have the history. ________________________________________________________________________________ 9.) TODO's ________________________________________________________________________________ - Hermite polynomial/function expansions - Sinc expansions - mapped methods - filters - object-oriented implementation. This will increase user-friendliness a great deal. It will also standardize calling syntax. - more general connections between spectral expansions - fast 'special function' zero calculations a la Glaser & Rohklin. ________________________________________________________________________________ 10.) Contact ________________________________________________________________________________ Any comments/suggestions/improvements/complaints are welcome. Akil Narayan anaray@dam.brown.edu
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。