├── LICENSE
└── MRBFT-1.0
├── LicenseMRBFT.txt
├── benchmarks
├── centroExtendedConditionNumberBench.m
├── condBench.m
├── dmFormBench.m
├── interpBenchExtended.m
├── multiplicationBench.m
└── systemSolveBench.m
├── examples
├── centroCenters.m
├── complexCentroCenters.m
├── condVaccuracy.m
├── diffusionReactionCentro.m
├── diffusionReactionCentroDriver.m
├── interp3d.m
├── interp3dCentro.m
├── mdiExample.m
├── mdiRegularization.m
├── poissonCentro.m
├── rbfInterpConvergence.m
├── rbfInterpConvergenceB.m
└── variableShapeInterp1d.m
├── functions
├── F1a.m
├── F2a.m
├── F2b.m
├── F2c.m
├── F2d.m
├── Function1d.m
└── Function2d.m
├── gax.m
├── iqx.m
├── rbfCenters.m
├── rbfCentro.m
├── rbfx.m
├── readme.md
└── tests
├── centroCondTest.m
├── centroSolveAccuracy.m
├── isCentroTest.m
└── rbfDerivativeTest.m
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/MRBFT-1.0/LicenseMRBFT.txt:
--------------------------------------------------------------------------------
1 |
2 | MRBFT license - GNU GPL V3
3 |
4 |
5 | GNU GENERAL PUBLIC LICENSE
6 | Version 3, 29 June 2007
7 |
8 | Copyright (C) 2007 Free Software Foundation, Inc.
9 | Everyone is permitted to copy and distribute verbatim copies
10 | of this license document, but changing it is not allowed.
11 |
12 | Preamble
13 |
14 | The GNU General Public License is a free, copyleft license for
15 | software and other kinds of works.
16 |
17 | The licenses for most software and other practical works are designed
18 | to take away your freedom to share and change the works. By contrast,
19 | the GNU General Public License is intended to guarantee your freedom to
20 | share and change all versions of a program--to make sure it remains free
21 | software for all its users. We, the Free Software Foundation, use the
22 | GNU General Public License for most of our software; it applies also to
23 | any other work released this way by its authors. You can apply it to
24 | your programs, too.
25 |
26 | When we speak of free software, we are referring to freedom, not
27 | price. Our General Public Licenses are designed to make sure that you
28 | have the freedom to distribute copies of free software (and charge for
29 | them if you wish), that you receive source code or can get it if you
30 | want it, that you can change the software or use pieces of it in new
31 | free programs, and that you know you can do these things.
32 |
33 | To protect your rights, we need to prevent others from denying you
34 | these rights or asking you to surrender the rights. Therefore, you have
35 | certain responsibilities if you distribute copies of the software, or if
36 | you modify it: responsibilities to respect the freedom of others.
37 |
38 | For example, if you distribute copies of such a program, whether
39 | gratis or for a fee, you must pass on to the recipients the same
40 | freedoms that you received. You must make sure that they, too, receive
41 | or can get the source code. And you must show them these terms so they
42 | know their rights.
43 |
44 | Developers that use the GNU GPL protect your rights with two steps:
45 | (1) assert copyright on the software, and (2) offer you this License
46 | giving you legal permission to copy, distribute and/or modify it.
47 |
48 | For the developers' and authors' protection, the GPL clearly explains
49 | that there is no warranty for this free software. For both users' and
50 | authors' sake, the GPL requires that modified versions be marked as
51 | changed, so that their problems will not be attributed erroneously to
52 | authors of previous versions.
53 |
54 | Some devices are designed to deny users access to install or run
55 | modified versions of the software inside them, although the manufacturer
56 | can do so. This is fundamentally incompatible with the aim of
57 | protecting users' freedom to change the software. The systematic
58 | pattern of such abuse occurs in the area of products for individuals to
59 | use, which is precisely where it is most unacceptable. Therefore, we
60 | have designed this version of the GPL to prohibit the practice for those
61 | products. If such problems arise substantially in other domains, we
62 | stand ready to extend this provision to those domains in future versions
63 | of the GPL, as needed to protect the freedom of users.
64 |
65 | Finally, every program is threatened constantly by software patents.
66 | States should not allow patents to restrict development and use of
67 | software on general-purpose computers, but in those that do, we wish to
68 | avoid the special danger that patents applied to a free program could
69 | make it effectively proprietary. To prevent this, the GPL assures that
70 | patents cannot be used to render the program non-free.
71 |
72 | The precise terms and conditions for copying, distribution and
73 | modification follow.
74 |
75 | TERMS AND CONDITIONS
76 |
77 | 0. Definitions.
78 |
79 | "This License" refers to version 3 of the GNU General Public License.
80 |
81 | "Copyright" also means copyright-like laws that apply to other kinds of
82 | works, such as semiconductor masks.
83 |
84 | "The Program" refers to any copyrightable work licensed under this
85 | License. Each licensee is addressed as "you". "Licensees" and
86 | "recipients" may be individuals or organizations.
87 |
88 | To "modify" a work means to copy from or adapt all or part of the work
89 | in a fashion requiring copyright permission, other than the making of an
90 | exact copy. The resulting work is called a "modified version" of the
91 | earlier work or a work "based on" the earlier work.
92 |
93 | A "covered work" means either the unmodified Program or a work based
94 | on the Program.
95 |
96 | To "propagate" a work means to do anything with it that, without
97 | permission, would make you directly or secondarily liable for
98 | infringement under applicable copyright law, except executing it on a
99 | computer or modifying a private copy. Propagation includes copying,
100 | distribution (with or without modification), making available to the
101 | public, and in some countries other activities as well.
102 |
103 | To "convey" a work means any kind of propagation that enables other
104 | parties to make or receive copies. Mere interaction with a user through
105 | a computer network, with no transfer of a copy, is not conveying.
106 |
107 | An interactive user interface displays "Appropriate Legal Notices"
108 | to the extent that it includes a convenient and prominently visible
109 | feature that (1) displays an appropriate copyright notice, and (2)
110 | tells the user that there is no warranty for the work (except to the
111 | extent that warranties are provided), that licensees may convey the
112 | work under this License, and how to view a copy of this License. If
113 | the interface presents a list of user commands or options, such as a
114 | menu, a prominent item in the list meets this criterion.
115 |
116 | 1. Source Code.
117 |
118 | The "source code" for a work means the preferred form of the work
119 | for making modifications to it. "Object code" means any non-source
120 | form of a work.
121 |
122 | A "Standard Interface" means an interface that either is an official
123 | standard defined by a recognized standards body, or, in the case of
124 | interfaces specified for a particular programming language, one that
125 | is widely used among developers working in that language.
126 |
127 | The "System Libraries" of an executable work include anything, other
128 | than the work as a whole, that (a) is included in the normal form of
129 | packaging a Major Component, but which is not part of that Major
130 | Component, and (b) serves only to enable use of the work with that
131 | Major Component, or to implement a Standard Interface for which an
132 | implementation is available to the public in source code form. A
133 | "Major Component", in this context, means a major essential component
134 | (kernel, window system, and so on) of the specific operating system
135 | (if any) on which the executable work runs, or a compiler used to
136 | produce the work, or an object code interpreter used to run it.
137 |
138 | The "Corresponding Source" for a work in object code form means all
139 | the source code needed to generate, install, and (for an executable
140 | work) run the object code and to modify the work, including scripts to
141 | control those activities. However, it does not include the work's
142 | System Libraries, or general-purpose tools or generally available free
143 | programs which are used unmodified in performing those activities but
144 | which are not part of the work. For example, Corresponding Source
145 | includes interface definition files associated with source files for
146 | the work, and the source code for shared libraries and dynamically
147 | linked subprograms that the work is specifically designed to require,
148 | such as by intimate data communication or control flow between those
149 | subprograms and other parts of the work.
150 |
151 | The Corresponding Source need not include anything that users
152 | can regenerate automatically from other parts of the Corresponding
153 | Source.
154 |
155 | The Corresponding Source for a work in source code form is that
156 | same work.
157 |
158 | 2. Basic Permissions.
159 |
160 | All rights granted under this License are granted for the term of
161 | copyright on the Program, and are irrevocable provided the stated
162 | conditions are met. This License explicitly affirms your unlimited
163 | permission to run the unmodified Program. The output from running a
164 | covered work is covered by this License only if the output, given its
165 | content, constitutes a covered work. This License acknowledges your
166 | rights of fair use or other equivalent, as provided by copyright law.
167 |
168 | You may make, run and propagate covered works that you do not
169 | convey, without conditions so long as your license otherwise remains
170 | in force. You may convey covered works to others for the sole purpose
171 | of having them make modifications exclusively for you, or provide you
172 | with facilities for running those works, provided that you comply with
173 | the terms of this License in conveying all material for which you do
174 | not control copyright. Those thus making or running the covered works
175 | for you must do so exclusively on your behalf, under your direction
176 | and control, on terms that prohibit them from making any copies of
177 | your copyrighted material outside their relationship with you.
178 |
179 | Conveying under any other circumstances is permitted solely under
180 | the conditions stated below. Sublicensing is not allowed; section 10
181 | makes it unnecessary.
182 |
183 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
184 |
185 | No covered work shall be deemed part of an effective technological
186 | measure under any applicable law fulfilling obligations under article
187 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
188 | similar laws prohibiting or restricting circumvention of such
189 | measures.
190 |
191 | When you convey a covered work, you waive any legal power to forbid
192 | circumvention of technological measures to the extent such circumvention
193 | is effected by exercising rights under this License with respect to
194 | the covered work, and you disclaim any intention to limit operation or
195 | modification of the work as a means of enforcing, against the work's
196 | users, your or third parties' legal rights to forbid circumvention of
197 | technological measures.
198 |
199 | 4. Conveying Verbatim Copies.
200 |
201 | You may convey verbatim copies of the Program's source code as you
202 | receive it, in any medium, provided that you conspicuously and
203 | appropriately publish on each copy an appropriate copyright notice;
204 | keep intact all notices stating that this License and any
205 | non-permissive terms added in accord with section 7 apply to the code;
206 | keep intact all notices of the absence of any warranty; and give all
207 | recipients a copy of this License along with the Program.
208 |
209 | You may charge any price or no price for each copy that you convey,
210 | and you may offer support or warranty protection for a fee.
211 |
212 | 5. Conveying Modified Source Versions.
213 |
214 | You may convey a work based on the Program, or the modifications to
215 | produce it from the Program, in the form of source code under the
216 | terms of section 4, provided that you also meet all of these conditions:
217 |
218 | a) The work must carry prominent notices stating that you modified
219 | it, and giving a relevant date.
220 |
221 | b) The work must carry prominent notices stating that it is
222 | released under this License and any conditions added under section
223 | 7. This requirement modifies the requirement in section 4 to
224 | "keep intact all notices".
225 |
226 | c) You must license the entire work, as a whole, under this
227 | License to anyone who comes into possession of a copy. This
228 | License will therefore apply, along with any applicable section 7
229 | additional terms, to the whole of the work, and all its parts,
230 | regardless of how they are packaged. This License gives no
231 | permission to license the work in any other way, but it does not
232 | invalidate such permission if you have separately received it.
233 |
234 | d) If the work has interactive user interfaces, each must display
235 | Appropriate Legal Notices; however, if the Program has interactive
236 | interfaces that do not display Appropriate Legal Notices, your
237 | work need not make them do so.
238 |
239 | A compilation of a covered work with other separate and independent
240 | works, which are not by their nature extensions of the covered work,
241 | and which are not combined with it such as to form a larger program,
242 | in or on a volume of a storage or distribution medium, is called an
243 | "aggregate" if the compilation and its resulting copyright are not
244 | used to limit the access or legal rights of the compilation's users
245 | beyond what the individual works permit. Inclusion of a covered work
246 | in an aggregate does not cause this License to apply to the other
247 | parts of the aggregate.
248 |
249 | 6. Conveying Non-Source Forms.
250 |
251 | You may convey a covered work in object code form under the terms
252 | of sections 4 and 5, provided that you also convey the
253 | machine-readable Corresponding Source under the terms of this License,
254 | in one of these ways:
255 |
256 | a) Convey the object code in, or embodied in, a physical product
257 | (including a physical distribution medium), accompanied by the
258 | Corresponding Source fixed on a durable physical medium
259 | customarily used for software interchange.
260 |
261 | b) Convey the object code in, or embodied in, a physical product
262 | (including a physical distribution medium), accompanied by a
263 | written offer, valid for at least three years and valid for as
264 | long as you offer spare parts or customer support for that product
265 | model, to give anyone who possesses the object code either (1) a
266 | copy of the Corresponding Source for all the software in the
267 | product that is covered by this License, on a durable physical
268 | medium customarily used for software interchange, for a price no
269 | more than your reasonable cost of physically performing this
270 | conveying of source, or (2) access to copy the
271 | Corresponding Source from a network server at no charge.
272 |
273 | c) Convey individual copies of the object code with a copy of the
274 | written offer to provide the Corresponding Source. This
275 | alternative is allowed only occasionally and noncommercially, and
276 | only if you received the object code with such an offer, in accord
277 | with subsection 6b.
278 |
279 | d) Convey the object code by offering access from a designated
280 | place (gratis or for a charge), and offer equivalent access to the
281 | Corresponding Source in the same way through the same place at no
282 | further charge. You need not require recipients to copy the
283 | Corresponding Source along with the object code. If the place to
284 | copy the object code is a network server, the Corresponding Source
285 | may be on a different server (operated by you or a third party)
286 | that supports equivalent copying facilities, provided you maintain
287 | clear directions next to the object code saying where to find the
288 | Corresponding Source. Regardless of what server hosts the
289 | Corresponding Source, you remain obligated to ensure that it is
290 | available for as long as needed to satisfy these requirements.
291 |
292 | e) Convey the object code using peer-to-peer transmission, provided
293 | you inform other peers where the object code and Corresponding
294 | Source of the work are being offered to the general public at no
295 | charge under subsection 6d.
296 |
297 | A separable portion of the object code, whose source code is excluded
298 | from the Corresponding Source as a System Library, need not be
299 | included in conveying the object code work.
300 |
301 | A "User Product" is either (1) a "consumer product", which means any
302 | tangible personal property which is normally used for personal, family,
303 | or household purposes, or (2) anything designed or sold for incorporation
304 | into a dwelling. In determining whether a product is a consumer product,
305 | doubtful cases shall be resolved in favor of coverage. For a particular
306 | product received by a particular user, "normally used" refers to a
307 | typical or common use of that class of product, regardless of the status
308 | of the particular user or of the way in which the particular user
309 | actually uses, or expects or is expected to use, the product. A product
310 | is a consumer product regardless of whether the product has substantial
311 | commercial, industrial or non-consumer uses, unless such uses represent
312 | the only significant mode of use of the product.
313 |
314 | "Installation Information" for a User Product means any methods,
315 | procedures, authorization keys, or other information required to install
316 | and execute modified versions of a covered work in that User Product from
317 | a modified version of its Corresponding Source. The information must
318 | suffice to ensure that the continued functioning of the modified object
319 | code is in no case prevented or interfered with solely because
320 | modification has been made.
321 |
322 | If you convey an object code work under this section in, or with, or
323 | specifically for use in, a User Product, and the conveying occurs as
324 | part of a transaction in which the right of possession and use of the
325 | User Product is transferred to the recipient in perpetuity or for a
326 | fixed term (regardless of how the transaction is characterized), the
327 | Corresponding Source conveyed under this section must be accompanied
328 | by the Installation Information. But this requirement does not apply
329 | if neither you nor any third party retains the ability to install
330 | modified object code on the User Product (for example, the work has
331 | been installed in ROM).
332 |
333 | The requirement to provide Installation Information does not include a
334 | requirement to continue to provide support service, warranty, or updates
335 | for a work that has been modified or installed by the recipient, or for
336 | the User Product in which it has been modified or installed. Access to a
337 | network may be denied when the modification itself materially and
338 | adversely affects the operation of the network or violates the rules and
339 | protocols for communication across the network.
340 |
341 | Corresponding Source conveyed, and Installation Information provided,
342 | in accord with this section must be in a format that is publicly
343 | documented (and with an implementation available to the public in
344 | source code form), and must require no special password or key for
345 | unpacking, reading or copying.
346 |
347 | 7. Additional Terms.
348 |
349 | "Additional permissions" are terms that supplement the terms of this
350 | License by making exceptions from one or more of its conditions.
351 | Additional permissions that are applicable to the entire Program shall
352 | be treated as though they were included in this License, to the extent
353 | that they are valid under applicable law. If additional permissions
354 | apply only to part of the Program, that part may be used separately
355 | under those permissions, but the entire Program remains governed by
356 | this License without regard to the additional permissions.
357 |
358 | When you convey a copy of a covered work, you may at your option
359 | remove any additional permissions from that copy, or from any part of
360 | it. (Additional permissions may be written to require their own
361 | removal in certain cases when you modify the work.) You may place
362 | additional permissions on material, added by you to a covered work,
363 | for which you have or can give appropriate copyright permission.
364 |
365 | Notwithstanding any other provision of this License, for material you
366 | add to a covered work, you may (if authorized by the copyright holders of
367 | that material) supplement the terms of this License with terms:
368 |
369 | a) Disclaiming warranty or limiting liability differently from the
370 | terms of sections 15 and 16 of this License; or
371 |
372 | b) Requiring preservation of specified reasonable legal notices or
373 | author attributions in that material or in the Appropriate Legal
374 | Notices displayed by works containing it; or
375 |
376 | c) Prohibiting misrepresentation of the origin of that material, or
377 | requiring that modified versions of such material be marked in
378 | reasonable ways as different from the original version; or
379 |
380 | d) Limiting the use for publicity purposes of names of licensors or
381 | authors of the material; or
382 |
383 | e) Declining to grant rights under trademark law for use of some
384 | trade names, trademarks, or service marks; or
385 |
386 | f) Requiring indemnification of licensors and authors of that
387 | material by anyone who conveys the material (or modified versions of
388 | it) with contractual assumptions of liability to the recipient, for
389 | any liability that these contractual assumptions directly impose on
390 | those licensors and authors.
391 |
392 | All other non-permissive additional terms are considered "further
393 | restrictions" within the meaning of section 10. If the Program as you
394 | received it, or any part of it, contains a notice stating that it is
395 | governed by this License along with a term that is a further
396 | restriction, you may remove that term. If a license document contains
397 | a further restriction but permits relicensing or conveying under this
398 | License, you may add to a covered work material governed by the terms
399 | of that license document, provided that the further restriction does
400 | not survive such relicensing or conveying.
401 |
402 | If you add terms to a covered work in accord with this section, you
403 | must place, in the relevant source files, a statement of the
404 | additional terms that apply to those files, or a notice indicating
405 | where to find the applicable terms.
406 |
407 | Additional terms, permissive or non-permissive, may be stated in the
408 | form of a separately written license, or stated as exceptions;
409 | the above requirements apply either way.
410 |
411 | 8. Termination.
412 |
413 | You may not propagate or modify a covered work except as expressly
414 | provided under this License. Any attempt otherwise to propagate or
415 | modify it is void, and will automatically terminate your rights under
416 | this License (including any patent licenses granted under the third
417 | paragraph of section 11).
418 |
419 | However, if you cease all violation of this License, then your
420 | license from a particular copyright holder is reinstated (a)
421 | provisionally, unless and until the copyright holder explicitly and
422 | finally terminates your license, and (b) permanently, if the copyright
423 | holder fails to notify you of the violation by some reasonable means
424 | prior to 60 days after the cessation.
425 |
426 | Moreover, your license from a particular copyright holder is
427 | reinstated permanently if the copyright holder notifies you of the
428 | violation by some reasonable means, this is the first time you have
429 | received notice of violation of this License (for any work) from that
430 | copyright holder, and you cure the violation prior to 30 days after
431 | your receipt of the notice.
432 |
433 | Termination of your rights under this section does not terminate the
434 | licenses of parties who have received copies or rights from you under
435 | this License. If your rights have been terminated and not permanently
436 | reinstated, you do not qualify to receive new licenses for the same
437 | material under section 10.
438 |
439 | 9. Acceptance Not Required for Having Copies.
440 |
441 | You are not required to accept this License in order to receive or
442 | run a copy of the Program. Ancillary propagation of a covered work
443 | occurring solely as a consequence of using peer-to-peer transmission
444 | to receive a copy likewise does not require acceptance. However,
445 | nothing other than this License grants you permission to propagate or
446 | modify any covered work. These actions infringe copyright if you do
447 | not accept this License. Therefore, by modifying or propagating a
448 | covered work, you indicate your acceptance of this License to do so.
449 |
450 | 10. Automatic Licensing of Downstream Recipients.
451 |
452 | Each time you convey a covered work, the recipient automatically
453 | receives a license from the original licensors, to run, modify and
454 | propagate that work, subject to this License. You are not responsible
455 | for enforcing compliance by third parties with this License.
456 |
457 | An "entity transaction" is a transaction transferring control of an
458 | organization, or substantially all assets of one, or subdividing an
459 | organization, or merging organizations. If propagation of a covered
460 | work results from an entity transaction, each party to that
461 | transaction who receives a copy of the work also receives whatever
462 | licenses to the work the party's predecessor in interest had or could
463 | give under the previous paragraph, plus a right to possession of the
464 | Corresponding Source of the work from the predecessor in interest, if
465 | the predecessor has it or can get it with reasonable efforts.
466 |
467 | You may not impose any further restrictions on the exercise of the
468 | rights granted or affirmed under this License. For example, you may
469 | not impose a license fee, royalty, or other charge for exercise of
470 | rights granted under this License, and you may not initiate litigation
471 | (including a cross-claim or counterclaim in a lawsuit) alleging that
472 | any patent claim is infringed by making, using, selling, offering for
473 | sale, or importing the Program or any portion of it.
474 |
475 | 11. Patents.
476 |
477 | A "contributor" is a copyright holder who authorizes use under this
478 | License of the Program or a work on which the Program is based. The
479 | work thus licensed is called the contributor's "contributor version".
480 |
481 | A contributor's "essential patent claims" are all patent claims
482 | owned or controlled by the contributor, whether already acquired or
483 | hereafter acquired, that would be infringed by some manner, permitted
484 | by this License, of making, using, or selling its contributor version,
485 | but do not include claims that would be infringed only as a
486 | consequence of further modification of the contributor version. For
487 | purposes of this definition, "control" includes the right to grant
488 | patent sublicenses in a manner consistent with the requirements of
489 | this License.
490 |
491 | Each contributor grants you a non-exclusive, worldwide, royalty-free
492 | patent license under the contributor's essential patent claims, to
493 | make, use, sell, offer for sale, import and otherwise run, modify and
494 | propagate the contents of its contributor version.
495 |
496 | In the following three paragraphs, a "patent license" is any express
497 | agreement or commitment, however denominated, not to enforce a patent
498 | (such as an express permission to practice a patent or covenant not to
499 | sue for patent infringement). To "grant" such a patent license to a
500 | party means to make such an agreement or commitment not to enforce a
501 | patent against the party.
502 |
503 | If you convey a covered work, knowingly relying on a patent license,
504 | and the Corresponding Source of the work is not available for anyone
505 | to copy, free of charge and under the terms of this License, through a
506 | publicly available network server or other readily accessible means,
507 | then you must either (1) cause the Corresponding Source to be so
508 | available, or (2) arrange to deprive yourself of the benefit of the
509 | patent license for this particular work, or (3) arrange, in a manner
510 | consistent with the requirements of this License, to extend the patent
511 | license to downstream recipients. "Knowingly relying" means you have
512 | actual knowledge that, but for the patent license, your conveying the
513 | covered work in a country, or your recipient's use of the covered work
514 | in a country, would infringe one or more identifiable patents in that
515 | country that you have reason to believe are valid.
516 |
517 | If, pursuant to or in connection with a single transaction or
518 | arrangement, you convey, or propagate by procuring conveyance of, a
519 | covered work, and grant a patent license to some of the parties
520 | receiving the covered work authorizing them to use, propagate, modify
521 | or convey a specific copy of the covered work, then the patent license
522 | you grant is automatically extended to all recipients of the covered
523 | work and works based on it.
524 |
525 | A patent license is "discriminatory" if it does not include within
526 | the scope of its coverage, prohibits the exercise of, or is
527 | conditioned on the non-exercise of one or more of the rights that are
528 | specifically granted under this License. You may not convey a covered
529 | work if you are a party to an arrangement with a third party that is
530 | in the business of distributing software, under which you make payment
531 | to the third party based on the extent of your activity of conveying
532 | the work, and under which the third party grants, to any of the
533 | parties who would receive the covered work from you, a discriminatory
534 | patent license (a) in connection with copies of the covered work
535 | conveyed by you (or copies made from those copies), or (b) primarily
536 | for and in connection with specific products or compilations that
537 | contain the covered work, unless you entered into that arrangement,
538 | or that patent license was granted, prior to 28 March 2007.
539 |
540 | Nothing in this License shall be construed as excluding or limiting
541 | any implied license or other defenses to infringement that may
542 | otherwise be available to you under applicable patent law.
543 |
544 | 12. No Surrender of Others' Freedom.
545 |
546 | If conditions are imposed on you (whether by court order, agreement or
547 | otherwise) that contradict the conditions of this License, they do not
548 | excuse you from the conditions of this License. If you cannot convey a
549 | covered work so as to satisfy simultaneously your obligations under this
550 | License and any other pertinent obligations, then as a consequence you may
551 | not convey it at all. For example, if you agree to terms that obligate you
552 | to collect a royalty for further conveying from those to whom you convey
553 | the Program, the only way you could satisfy both those terms and this
554 | License would be to refrain entirely from conveying the Program.
555 |
556 | 13. Use with the GNU Affero General Public License.
557 |
558 | Notwithstanding any other provision of this License, you have
559 | permission to link or combine any covered work with a work licensed
560 | under version 3 of the GNU Affero General Public License into a single
561 | combined work, and to convey the resulting work. The terms of this
562 | License will continue to apply to the part which is the covered work,
563 | but the special requirements of the GNU Affero General Public License,
564 | section 13, concerning interaction through a network will apply to the
565 | combination as such.
566 |
567 | 14. Revised Versions of this License.
568 |
569 | The Free Software Foundation may publish revised and/or new versions of
570 | the GNU General Public License from time to time. Such new versions will
571 | be similar in spirit to the present version, but may differ in detail to
572 | address new problems or concerns.
573 |
574 | Each version is given a distinguishing version number. If the
575 | Program specifies that a certain numbered version of the GNU General
576 | Public License "or any later version" applies to it, you have the
577 | option of following the terms and conditions either of that numbered
578 | version or of any later version published by the Free Software
579 | Foundation. If the Program does not specify a version number of the
580 | GNU General Public License, you may choose any version ever published
581 | by the Free Software Foundation.
582 |
583 | If the Program specifies that a proxy can decide which future
584 | versions of the GNU General Public License can be used, that proxy's
585 | public statement of acceptance of a version permanently authorizes you
586 | to choose that version for the Program.
587 |
588 | Later license versions may give you additional or different
589 | permissions. However, no additional obligations are imposed on any
590 | author or copyright holder as a result of your choosing to follow a
591 | later version.
592 |
593 | 15. Disclaimer of Warranty.
594 |
595 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
596 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
597 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
598 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
599 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
600 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
601 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
602 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
603 |
604 | 16. Limitation of Liability.
605 |
606 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
607 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
608 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
609 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
610 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
611 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
612 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
613 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
614 | SUCH DAMAGES.
615 |
616 | 17. Interpretation of Sections 15 and 16.
617 |
618 | If the disclaimer of warranty and limitation of liability provided
619 | above cannot be given local legal effect according to their terms,
620 | reviewing courts shall apply local law that most closely approximates
621 | an absolute waiver of all civil liability in connection with the
622 | Program, unless a warranty or assumption of liability accompanies a
623 | copy of the Program in return for a fee.
624 |
625 | END OF TERMS AND CONDITIONS
626 |
627 | How to Apply These Terms to Your New Programs
628 |
629 | If you develop a new program, and you want it to be of the greatest
630 | possible use to the public, the best way to achieve this is to make it
631 | free software which everyone can redistribute and change under these terms.
632 |
633 | To do so, attach the following notices to the program. It is safest
634 | to attach them to the start of each source file to most effectively
635 | state the exclusion of warranty; and each file should have at least
636 | the "copyright" line and a pointer to where the full notice is found.
637 |
638 | {one line to give the program's name and a brief idea of what it does.}
639 | Copyright (C) {year} {name of author}
640 |
641 | This program is free software: you can redistribute it and/or modify
642 | it under the terms of the GNU General Public License as published by
643 | the Free Software Foundation, either version 3 of the License, or
644 | (at your option) any later version.
645 |
646 | This program is distributed in the hope that it will be useful,
647 | but WITHOUT ANY WARRANTY; without even the implied warranty of
648 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
649 | GNU General Public License for more details.
650 |
651 | You should have received a copy of the GNU General Public License
652 | along with this program. If not, see .
653 |
654 | Also add information on how to contact you by electronic and paper mail.
655 |
656 | If the program does terminal interaction, make it output a short
657 | notice like this when it starts in an interactive mode:
658 |
659 | {project} Copyright (C) {year} {fullname}
660 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
661 | This is free software, and you are welcome to redistribute it
662 | under certain conditions; type `show c' for details.
663 |
664 | The hypothetical commands `show w' and `show c' should show the appropriate
665 | parts of the General Public License. Of course, your program's commands
666 | might be different; for a GUI interface, you would use an "about box".
667 |
668 | You should also get your employer (if you work as a programmer) or school,
669 | if any, to sign a "copyright disclaimer" for the program, if necessary.
670 | For more information on this, and how to apply and follow the GNU GPL, see
671 | .
672 |
673 | The GNU General Public License does not permit incorporating your program
674 | into proprietary programs. If your program is a subroutine library, you
675 | may consider it more useful to permit linking proprietary applications with
676 | the library. If this is what you want to do, use the GNU Lesser General
677 | Public License instead of this License. But first, please read
678 | .
679 |
--------------------------------------------------------------------------------
/MRBFT-1.0/benchmarks/centroExtendedConditionNumberBench.m:
--------------------------------------------------------------------------------
1 | % centroExtendedConditionNumberBench.m
2 | %
3 | % Compares the execution times of centrosymmetric and standard algorithms
4 | % for the 2-norm condition number using both double and quadruple precision.
5 |
6 | % sample output (old MCT on Linux)
7 | % centroExtendedConditionNumberBench
8 | % double: standard = 0.574
9 | % double: centro = 0.149
10 | % double: standard to centro = 3.850
11 | %
12 | % extended: standard = 154.553
13 | % extended: centro = 51.310
14 | % extended: standard to centro = 3.012
15 |
16 | clear, home, format compact
17 |
18 | phi = iqx();
19 |
20 | N = 2000;
21 | s = 8;
22 | mu = 0;
23 | [xc,yc] = rbfCentro.centroCircle(N,true,0,1,false);
24 | N = length(xc);
25 |
26 | % ------------------- double ------------------------------------
27 |
28 | tic
29 | r = phi.distanceMatrix2d(xc(1:N/2),yc(1:N/2),xc,yc); % construct half-sized distance matrix
30 | B = phi.rbf(r,s); % half-sized system matrix
31 | [kappaB, kappaL, kappaM] = rbfCentro.centroConditionNumber(B,mu);
32 | cTime = toc;
33 |
34 |
35 |
36 | tic
37 | r = phi.distanceMatrix2d(xc,yc);
38 | B = phi.rbf(r,s);
39 | kappa = cond(B);
40 | ncTime = toc;
41 |
42 |
43 | fprintf('double: standard = %4.3f\n',ncTime);
44 | fprintf('double: centro = %4.3f\n',cTime);
45 | fprintf('double: standard to centro = %4.3f\n',ncTime/cTime);
46 | disp(' ')
47 |
48 |
49 | % -------------------- extended ---------------------------------------
50 |
51 | mp.Digits(34);
52 |
53 | N = 2000;
54 | s = mp('8');
55 | mu = 0;
56 | [xc,yc] = rbfCentro.centroCircle(N,true,0,1,false);
57 | N = length(xc);
58 | xc = mp(xc); yc = mp(yc);
59 |
60 | % ------------------------------------------------------------------------
61 |
62 | tic
63 | r = phi.distanceMatrix2d(xc(1:N/2),yc(1:N/2),xc,yc); % construct half-sized distance matrix
64 | B = phi.rbf(r,s); % half-sized system matrix
65 | [kappaB, kappaL, kappaM] = rbfCentro.centroConditionNumber(B,mu);
66 | cTime = toc;
67 |
68 |
69 |
70 | tic
71 | r = phi.distanceMatrix2d(xc,yc);
72 | B = phi.rbf(r,s);
73 | kappa = cond(B);
74 | ncTime = toc;
75 |
76 |
77 | fprintf('extended: standard = %4.3f\n',ncTime);
78 | fprintf('extended: centro = %4.3f\n',cTime);
79 | fprintf('extended: standard to centro = %4.3f\n',ncTime/cTime);
80 | disp(' ')
81 |
82 |
83 |
--------------------------------------------------------------------------------
/MRBFT-1.0/benchmarks/condBench.m:
--------------------------------------------------------------------------------
1 | % condBench.m
2 | %
3 | % Compares the execution times of centrosymmetric versus standard algorithms for
4 | % calculating the 2-norm condition number of a centrosymmetric matrix
5 |
6 | clear, home, format compact
7 |
8 | phi = iqx();
9 | s = 230;
10 | mu = 0;
11 | its = 5;
12 |
13 | Nv = 600:250:2100;
14 |
15 | Ns = length(Nv);
16 | cTime = zeros(Ns,1);
17 | ncTime = zeros(Ns,1);
18 |
19 |
20 | tic
21 | for k=1:Ns
22 | N = Nv(k);
23 | x = linspace(-100,100,N)';
24 | f = rand(N,1);
25 | tic
26 | for j=1:its
27 | r = phi.distanceMatrix1d(x(1:N/2),x); % construct half-sized distance matrix
28 | B = phi.rbf(r,s); % half-sized system matrix
29 | [kappaB, kappaL, kappaM] = rbfCentro.centroConditionNumber(B,mu);
30 | end
31 | cTime(k) = toc;
32 | end
33 |
34 |
35 | for k=1:Ns
36 | N = Nv(k);
37 | x = linspace(-1,1,N)';
38 | f = rand(N,1);
39 | tic
40 | for j=1:its
41 | r = phi.distanceMatrix1d(x);
42 | B = phi.rbf(r,s);
43 | kappa = cond(B);
44 | end
45 | ncTime(k) = toc;
46 | end
47 |
48 |
49 | plot(Nv,cTime./ncTime,'b*',Nv,ones(Ns,1),'g--')
50 | xlabel('N'), ylabel('execution time ratio')
--------------------------------------------------------------------------------
/MRBFT-1.0/benchmarks/dmFormBench.m:
--------------------------------------------------------------------------------
1 | % dmFormBench.m
2 | %
3 | % compares the execution times of centro versus standard algorithms
4 | % for constructing a centro derivative matrix
5 |
6 | clear, home, format compact
7 |
8 | phi = iqx();
9 | s = 230;
10 | rho = 1;
11 | safe = true;
12 | mu = 0;
13 | its = 10;
14 |
15 | Nv = 350:250:2100;
16 | Ns = length(Nv);
17 | cTime = zeros(Ns,1);
18 | ncTime = zeros(Ns,1);
19 |
20 |
21 | tic
22 | for k=1:Ns
23 | N = Nv(k);
24 | x = linspace(-1,1,N)';
25 | tic
26 | for j=1:its
27 | r = phi.distanceMatrix1d(x(1:N/2),x); % half-sized distance matrix
28 | B = phi.rbf(r,s);
29 | H = phi.D1(r,s,r);
30 | D = rbfCentro.centroDM(B,H,N,rho,mu,safe);
31 | end
32 | cTime(k) = toc;
33 | end
34 |
35 |
36 | for k=1:Ns
37 | N = Nv(k);
38 | x = linspace(-1,1,N)';
39 | tic
40 | for j=1:its
41 | r = phi.distanceMatrix1d(x); % full-sized distance matrix
42 | B = phi.rbf(r,s);
43 | H = phi.D1(r,s,r);
44 | D = phi.dm(B,H,mu,safe);
45 | end
46 | ncTime(k) = toc;
47 | end
48 |
49 |
50 | plot(Nv,cTime./ncTime,'b*')
51 | xlabel('N'), ylabel('execution time ratio')
52 |
53 |
--------------------------------------------------------------------------------
/MRBFT-1.0/benchmarks/interpBenchExtended.m:
--------------------------------------------------------------------------------
1 | % interpBenchExtended.m
2 |
3 | warning off
4 | tic
5 |
6 | QUAD = true; % true for quadruple precision, false for double
7 |
8 | K = 1.5*sqrt(2);
9 | XC = dlmread('xc.txt',' '); xc = XC(:,1)/K; yc = XC(:,2)/K; % centers
10 | X = dlmread('x.txt',' '); x = X(:,1)/K; y = X(:,2)/K; % evaluation points
11 |
12 | if QUAD % convert centers/execution points to extended, then all other calcs done in xprec
13 | mp.Digits(34); x = mp(x); y = mp(y); xc = mp(xc); yc = mp(yc);
14 | end
15 |
16 | N = length(xc); M = length(x);
17 |
18 | fn = F2d(); % Franke function
19 | f = fn.F(xc,yc);
20 | fe = fn.F(x,y);
21 |
22 | phi = iqx();
23 |
24 | [r, rx, ry] = rbfx.distanceMatrix2d(xc,yc);
25 | [re, rx, ry] = rbfx.distanceMatrix2d(xc,yc,x,y);
26 |
27 | S = 7.2:-0.5:0.2; Sn = length(S);
28 | for k = 1:Sn
29 | s = S(k);
30 | B = phi.rbf(r,s);
31 | a = rbfx.solve(B,f);
32 | H = phi.rbf(re,s);
33 | fa = H*a;
34 | end
35 |
36 | if QUAD, tx = toc, else, td = toc, end
37 |
38 |
39 | % after running the script in both precisions the ration of times is:
40 | % tx/td % ratio of execution times
41 | % 352.4308 % typical ratio - quadruple takes over 350 times longer
42 |
43 | warning on
44 |
--------------------------------------------------------------------------------
/MRBFT-1.0/benchmarks/multiplicationBench.m:
--------------------------------------------------------------------------------
1 | % multiplicationBench.m
2 | %
3 | % compares the execution time of centro versus the standard algorithm for
4 | % matrix-vector multiplication
5 |
6 | clear, home, format compact
7 |
8 | phi = iqx();
9 | s = 230;
10 | rho = 1;
11 | safe = true; % use backslash operator
12 | mu = 0; % no regularization
13 | its = 25;
14 |
15 | Nv = 600:100:3000;
16 | Ns = length(Nv);
17 | cTime = zeros(Ns,1);
18 | ncTime = zeros(Ns,1);
19 |
20 |
21 | for k=1:Ns
22 | N = Nv(k);
23 | x = linspace(-1,1,N)';
24 | u = rand(N,1);
25 | r = phi.distanceMatrix1d(x(1:N/2),x);
26 | B = phi.rbf(r,s);
27 | H = phi.D1(r,s,r);
28 | D = rbfCentro.centroDM(B,H,N,rho,mu,safe);
29 | [L,M] = rbfCentro.centroDecomposeMatrix(D,rho);
30 | tic
31 | for j=1:its
32 | uac = rbfCentro.centroMult(u,L,M,rho);
33 | end
34 | cTime(k) = toc;
35 | end
36 |
37 |
38 | for k=1:Ns
39 | N = Nv(k);
40 | u = rand(N,1);
41 | x = linspace(-1,1,N)';
42 | r = phi.distanceMatrix1d(x);
43 | B = phi.rbf(r,s);
44 | H = phi.D1(r,s,r);
45 | D = phi.dm(B,H,mu,safe);
46 | tic
47 | for j=1:its
48 | ua = D*u;
49 | end
50 | ncTime(k) = toc;
51 | end
52 |
53 | plot(Nv,cTime./ncTime,'b*')
54 | xlabel('N'), ylabel('execution time ratio')
55 |
56 |
--------------------------------------------------------------------------------
/MRBFT-1.0/benchmarks/systemSolveBench.m:
--------------------------------------------------------------------------------
1 | % systemSolveBench.m
2 | %
3 | % Compares the evaluation times of centrosymmetric versus standard algorithms
4 | % for the solution of a centrosymmetric linear system
5 |
6 | clear, home, format compact
7 |
8 | phi = iqx();
9 | s = 330;
10 | rho = 0;
11 | safe = false; % use Cholesky factorization
12 | mu = 5e-15; % MDI regularization parameter
13 | its = 5;
14 |
15 | Nv = 350:250:4100;
16 | Ns = length(Nv);
17 | cTime = zeros(Ns,1);
18 | ncTime = zeros(Ns,1);
19 |
20 | tic
21 | for k=1:Ns % centrosymmetric
22 | N = Nv(k);
23 | x = linspace(-100,100,N)';
24 | f = rand(N,1);
25 | tic
26 | for j=1:its
27 | r = phi.distanceMatrix1d(x(1:N/2),x); % half sized distance matrix
28 | B = phi.rbf(r,s); % half sized system matrix
29 | a = rbfCentro.solveCentro(B,f,mu,safe);
30 | end
31 | cTime(k) = toc;
32 | end
33 |
34 | for k=1:Ns % standard
35 | N = Nv(k);
36 | x = linspace(-1,1,N)';
37 | f = rand(N,1);
38 | tic
39 | for j=1:its
40 | r = phi.distanceMatrix1d(x);
41 | B = phi.rbf(r,s);
42 | a = phi.solve(B,f,mu,safe);
43 | end
44 | ncTime(k) = toc;
45 | end
46 |
47 | plot(Nv,cTime./ncTime,'b*')
48 | xlabel('N'), ylabel('execution time ratio')
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/centroCenters.m:
--------------------------------------------------------------------------------
1 | % centroCenters.m
2 | %
3 | % Distributes Hammersley points in a complexly shaped domain. The centers
4 | % denser in near the boundary than in the interior.
5 |
6 | f = @(t) 3*nthroot( cos(3*t) + sqrt(4 - (sin(3*t)).^2), 3 ); % domain boundary
7 |
8 | small = 0.005;
9 | N = 6000; % N potiential centers in boundary region
10 | boundaryLayerSize = 0.5;
11 |
12 | t = linspace(0,2*pi,200);
13 | x = f(t).*cos(t); y = f(t).*sin(t);
14 |
15 | % determine the size of the rectangle needed to cover the domain
16 | A = min(x) - small; B = max(x) + small;
17 | C = min(y) - small; D = max(y) + small;
18 |
19 | [xc, yc] = rbfCenters.Hammersley2d(N);
20 | xc = (B - A)*xc + A; % [0,1] --> [A,B]
21 | yc = (D - C)*yc + C; % [0,1] --> [C,D]
22 |
23 | % ---------- boundary region centers -----------------------
24 |
25 | th = atan2(yc,xc); p = sqrt(xc.^2 + yc.^2);
26 | ro = f(th); % outter boundary
27 | ri = ro - boundaryLayerSize; % inner border of boundary region
28 |
29 | xn = zeros(N,1); yn = zeros(N,1); I = 1;
30 | for i=1:N
31 | if and( p(i) < ro(i), p(i)>ri(i) )
32 | xn(I) = xc(i); yn(I) = yc(i); I = I + 1;
33 | end
34 | end
35 | xc = xn(1:find(xn,1,'last')); % remove trailing zeros
36 | yc = yn(1:find(yn,1,'last'));
37 |
38 | % ------ interior centers----------------------------
39 |
40 | N2 = 2100; % N2 potiential centers in interior region
41 | [xci, yci] = rbfCenters.Hammersley2d(N2);
42 |
43 | A = A + boundaryLayerSize; B = B - boundaryLayerSize;
44 | C = C + boundaryLayerSize; D = D - boundaryLayerSize;
45 | xci = (B - A)*xci + A; % [0,1] --> [A,B]
46 | yci = (D - C)*yci + C; % [0,1] --> [C,D]
47 |
48 | th = atan2(yci,xci); p = sqrt(xci.^2 + yci.^2);
49 | ri = f(th) - boundaryLayerSize; % interior region boundary
50 |
51 | xn = zeros(N2,1); yn = zeros(N2,1); I = 1;
52 | for i=1:N2
53 | if p(i)<(ri(i) - small)
54 | xn(I) = xci(i); yn(I) = yci(i); I = I + 1;
55 | end
56 | end
57 |
58 | xci = xn(1:find(xn,1,'last')); % remove trailing zeros
59 | yci = yn(1:find(yn,1,'last'));
60 | x = [xc; xci]; y = [yc; yci]; % merge centers
61 |
62 |
63 | % --find centers in half of the domain (x-axis symmetry) ----------
64 |
65 | I = find(y>(0 + 0e-3 )); x = x(I); y = y(I);
66 |
67 | % ------ extend "centro-symmetrically" to the other half -----------
68 |
69 | x = [x; flipud(x)]; y = [y; flipud(-y)];
70 |
71 | % ---------------- verify centrosymmetry --------------------------
72 |
73 | r = abs(rbfx.distanceMatrix2d(x,y));
74 | centro = rbfCentro.isCentro(r)
75 |
76 | % -----------------------------------------------------------------
77 | scatter(x,y,'b.')
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/complexCentroCenters.m:
--------------------------------------------------------------------------------
1 | % complexCentroCenters.m
2 | %
3 | % Contructs a centro center distribution on a complexly shaped domain
4 | % using quasi-random Hammersley points which are placed denser near the
5 | % boundary than in the interior. Before the centers are extended
6 | % centrosymmetrically, the domain needs to be rotated so that it is symmetric
7 | % with respect to the x-axis. A different rotation could be used to make
8 | % the domain symmetric with repect to the origin.
9 |
10 | f = @(t) 0.8 + 0.1*( sin(6*t) + sin(3*t) ); % domain boundary
11 |
12 | small = 0.005;
13 | N = 5000; % N potiential centers in boundary region
14 | boundaryLayerSize = 0.2; % width of region with denser centers
15 |
16 | % determine the size of the rectangle needed to cover the domain
17 |
18 | t = linspace(0,2*pi,200);
19 | x = f(t).*cos(t); y = f(t).*sin(t);
20 | A = min(x) - small; B = max(x) + small;
21 | C = min(y) - small; D = max(y) + small;
22 |
23 | [xc, yc] = rbfCenters.Hammersley2d(N);
24 | xc = (B - A)*xc + A; % [0,1] --> [A,B]
25 | yc = (D - C)*yc + C; % [0,1] --> [C,D]
26 |
27 | % ---------- boundary region centers -----------------------
28 |
29 | th = atan2(yc,xc); p = sqrt(xc.^2 + yc.^2);
30 | ro = f(th); % outter boundary
31 | ri = ro - boundaryLayerSize; % inner border of boundary region
32 |
33 | xn = zeros(N,1); yn = zeros(N,1); I = 1;
34 | for i=1:N
35 | if and( p(i) < ro(i), p(i)>ri(i) )
36 | xn(I) = xc(i); yn(I) = yc(i); I = I + 1;
37 | end
38 | end
39 | xc = xn(1:find(xn,1,'last')); % remove trailing zeros
40 | yc = yn(1:find(yn,1,'last'));
41 |
42 | % ------ interior centers----------------------------
43 |
44 | N2 = 1750; % N2 potiential centers in interior region
45 | [xci, yci] = rbfCenters.Hammersley2d(N2);
46 |
47 | A = A + boundaryLayerSize; B = B - boundaryLayerSize;
48 | C = C + boundaryLayerSize; D = D - boundaryLayerSize;
49 | xci = (B - A)*xci + A; % [0,1] --> [A,B]
50 | yci = (D - C)*yci + C; % [0,1] --> [C,D]
51 |
52 | th = atan2(yci,xci); p = sqrt(xci.^2 + yci.^2);
53 | ri = f(th) - boundaryLayerSize; % interior region boundary
54 |
55 | xn = zeros(N2,1); yn = zeros(N2,1); I = 1;
56 | for i=1:N2
57 | if p(i)<(ri(i) - small)
58 | xn(I) = xci(i); yn(I) = yci(i); I = I + 1;
59 | end
60 | end
61 |
62 | xci = xn(1:find(xn,1,'last')); % remove trailing zeros
63 | yci = yn(1:find(yn,1,'last'));
64 | x = [xc; xci]; y = [yc; yci]; % merge centers
65 |
66 | % --------- rotate the domain clockwise 0.25 radians ----------------------
67 | % --- so that it is symmetric wrt the x-axis ------------------------------
68 |
69 | t = atan2(y,x) - 0.25; r = sqrt(x.^2 + y.^2);
70 | x = r.*cos(t); y = r.*sin(t);
71 |
72 | % --find centers in upper half of the domain (x-axis symmetry) ----------
73 |
74 | I = find(y>(0 + 1e-3 )); x = x(I); y = y(I);
75 |
76 | % ------ extend "centrosymmetrically" to the other half -----------------
77 |
78 | x = [x; flipud(x)]; y = [y; flipud(-y)];
79 | [r, rx, ry] = rbfx.distanceMatrix2d(x,y);
80 |
81 | disp(' ')
82 | % the signed distance matrix rx is NOT skew-centro => only even order DMs
83 | % wrt x will be centrosymmetric, odd order DMs wrt x will NOT be skew-centro
84 | fprintf('rx: '); rbfCentro.hasSymmetry(rx);
85 | % the signed distance matrix ry is skew-centro
86 | fprintf('ry: '); rbfCentro.hasSymmetry(ry);
87 | % the distance matrix r is centrosymmetric
88 | fprintf('r: '); rbfCentro.hasSymmetry(r);
89 |
90 | % ---------------- rotate back to the original position -----------
91 | % ------------ after any centro calculations are made -------------
92 |
93 | t = atan2(y,x) + 0.25; r = sqrt(x.^2 + y.^2);
94 | x = r.*cos(t); y = r.*sin(t);
95 |
96 | % -----------------------------------------------------------------
97 | scatter(x,y,'b.')
98 |
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/condVaccuracy.m:
--------------------------------------------------------------------------------
1 | % condVaccuracy.m
2 |
3 | warning off
4 | QUADRUPLE = false;
5 |
6 | phi = iqx();
7 | mu = 0; % MDI regularization parameter
8 | safe = true; % backslash rather than forcing Cholesky
9 | S = 3:-0.1:0.1; % shape parameters
10 | Sn = length(S);
11 | M = 175;
12 |
13 | if QUADRUPLE
14 | mp.Digits(34); N = mp('55'); pi = mp('pi'); kappa = mp(zeros(Sn,1)); er = mp(zeros(Sn,1)); % quadruple
15 | else
16 | N = 55; kappa = zeros(Sn,1); er = zeros(Sn,1); % double
17 | end
18 |
19 |
20 | gamma = 0.99;
21 | xc = (asin(-gamma*cos(pi*(0:N-1)/(N-1)))/asin(gamma))'; % boundary clustered centers
22 | r = rbfx.distanceMatrix1d(xc);
23 | x = linspace(-1,1,M)'; % evaluation points
24 | x = mp(x);
25 | re = rbfx.distanceMatrix1d(xc,x);
26 |
27 | f = exp(sin(pi*xc));
28 | fe = exp(sin(pi*x));
29 |
30 | for k = 1:Sn
31 | s = S(k);
32 | B = phi.rbf(r,s);
33 | kappa(k) = cond(B);
34 | a = rbfx.solve(B,f,mu,safe);
35 | H = phi.rbf(re,s);
36 | fa = H*a;
37 | er(k) = norm(fa - fe, inf);
38 | end
39 |
40 | %semilogy(S,kappa,'b') % plot condition number versus shape
41 | %xlabel('shape parameter'), ylabel('\kappa(B)')
42 | %
43 | % figure()
44 |
45 | semilogy(S,er,'b') % plot error versus shape parameter
46 | xlabel('shape parameter'), ylabel('|error|')
47 |
48 | warning on
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/diffusionReactionCentro.m:
--------------------------------------------------------------------------------
1 | % called by diffusionReactionCentroDriver.m
2 |
3 |
4 | function u = diffusionReactionCentro(xc,yc,bi,visc,dt,finalT,CENTRO,s)
5 |
6 | GAMMA = 1/visc;
7 | a = sqrt(GAMMA/(4*visc));
8 | b = sqrt(GAMMA*visc);
9 | c = a*(b-1);
10 |
11 | function v = rk4(V,t,k,F) % 4th order Runge-Kutta
12 | s1 = feval(F,V,t);
13 | s2 = feval(F,V + k*s1/2,t+k/2);
14 | s3 = feval(F,V + k*s2/2,t+k/2);
15 | s4 = feval(F,V + k*s3,t+k);
16 | v = V + k*(s1 + 2*s2 + 2*s3 + s4)/6;
17 | end
18 |
19 | function ex = exact(x,y,t)
20 | ex = 1./( 1 + exp( a*(x + y - b*t ) + c ) );
21 | end
22 |
23 | function fp = fStandard(V,t,dt) % u_t = F(u), standard
24 | V(bi) = exact(xc(bi), yc(bi), t);
25 | fp = visc*DS*V + GAMMA*(V.^2).*(1 - V);
26 | end
27 |
28 | function fp = fCentro(V,t,dt) % u_t = F(u), centrosymmetry
29 | V(bi) = exact(xc(bi), yc(bi), t);
30 | fp = visc*rbfCentro.centroMult(V,L,M,2) + GAMMA*(V.^2).*(1 - V);
31 | end
32 |
33 | safe = false;
34 | mu = 5e-15;
35 | phi = iqx();
36 | t = 0;
37 | U = exact(xc,yc,0); % initial condition
38 |
39 |
40 | if CENTRO
41 | N = length(xc);
42 | tic
43 | [r, rx, ry] = phi.distanceMatrix2d(xc(1:N/2),yc(1:N/2),xc,yc);
44 | B = phi.rbf(r,s);
45 | H = phi.L(r, s);
46 | [kappaB, kappaL, kappaM] = rbfCentro.centroConditionNumber(B,mu)
47 |
48 | D = rbfCentro.centroDM(B,H,N,2,mu,safe);
49 | [L,M] = rbfCentro.centroDecomposeMatrix(D,2);
50 |
51 | while t(1-100*eps));
41 |
42 |
43 | xc = 10*xc + 5; % domain of a radius 10 circle centered at (5,5)
44 | yc = 10*yc + 5;
45 |
46 | sol = diffusionReactionCentro(xc,yc,I,visc,dt,finalT,CENTRO,shape);
47 |
48 | td = delaunay(xc,yc);
49 | trisurf(td,xc,yc,sol);
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/interp3d.m:
--------------------------------------------------------------------------------
1 | % interp3d.m
2 | %
3 | % Gaussian RBF interpolation on the surface of a sphere.
4 | %
5 |
6 | warning off
7 | tic
8 |
9 | phi = gax();
10 | mu = 1.5e-13;
11 | safe = false;
12 | N = 6000;
13 | M = 7000;
14 |
15 | % http://www.mathworks.com/matlabcentral/fileexchange/6977-pointonsphere/content/pointonsphere.m
16 | P = pointonsphere(N);
17 | xc = P(:,1); yc = P(:,2); zc = P(:,3);
18 |
19 | P = pointonsphere(M);
20 | x = P(:,1); y = P(:,2); z = P(:,3);
21 |
22 | f = 0.1*( 9*xc.^3 - 2*xc.^2.*yc + 3*xc.*yc.^2 - 4*yc.^3 + 2*zc.^3 - xc.*yc.*zc );
23 | fe = 0.1*( 9*x.^3 - 2*x.^2.*y + 3*x.*y.^2 - 4*y.^3 + 2*z.^3 - x.*y.*z );
24 |
25 | [r,rx,ry,rz] = phi.distanceMatrix3d(xc,yc,zc);
26 | [re,rx,ry,rz] = phi.distanceMatrix3d(xc,yc,zc,x,y,z);
27 |
28 |
29 | sv = 8.1:-1:0.1;
30 | Ns = length(sv);
31 |
32 | er = zeros(Ns,1);
33 | for i=1:Ns
34 | s = sv(i)
35 | B = phi.rbf(r,s);
36 | a = phi.solve(B,f,mu,safe);
37 | H = phi.rbf(re,s);
38 | fa = H*a;
39 | er(i) = norm(fa - fe, inf);
40 | end
41 |
42 | toc
43 | semilogy(sv,er,'b--')
44 | warning
45 |
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/interp3dCentro.m:
--------------------------------------------------------------------------------
1 | % interp3dCentro.m
2 | %
3 | % Gaussian RBF interpolation on the surface of a sphere as in interp3d.m
4 | % but with a centrosymmetric center distribution. The system matrix as
5 | % well as all order differentiation matrices will have a centro structure.
6 | % The centrosymmetric approach executes in approximately half the time
7 | % that the standard approach takes.
8 | warning off
9 | tic
10 |
11 | phi = gax();
12 | mu = 1.5e-13;
13 | safe = false;
14 | N = 6000;
15 | M = 7000;
16 |
17 | % http://www.mathworks.com/matlabcentral/fileexchange/6977-pointonsphere/content/pointonsphere.m
18 | P = pointonsphere(N);
19 | xc = P(:,1); yc = P(:,2); zc = P(:,3);
20 |
21 | I = find( yc>xc );
22 | xc = [xc(I); flipud(-xc(I))];
23 | yc = [yc(I); flipud(-yc(I))];
24 | zc = [zc(I); flipud(-zc(I))];
25 | %scatter3(xc,yc,zc,'b.')
26 |
27 | P = pointonsphere(M);
28 | x = P(:,1); y = P(:,2); z = P(:,3);
29 |
30 | f = 0.1*( 9*xc.^3 - 2*xc.^2.*yc + 3*xc.*yc.^2 - 4*yc.^3 + 2*zc.^3 - xc.*yc.*zc );
31 | fe = 0.1*( 9*x.^3 - 2*x.^2.*y + 3*x.*y.^2 - 4*y.^3 + 2*z.^3 - x.*y.*z );
32 |
33 | [r,rx,ry,rz] = phi.distanceMatrix3d(xc,yc,zc);
34 | %rbfCentro.hasSymmetry(r); % verify centrosymmetry
35 |
36 | N = length(xc);
37 | [r,rx,ry,rz] = phi.distanceMatrix3d(xc(1:N/2),yc(1:N/2),zc(1:N/2),xc,yc,zc); % construct half-sized distance matrix
38 | [re,rx,ry,rz] = phi.distanceMatrix3d(xc,yc,zc,x,y,z);
39 |
40 | sv = 8.1:-1:0.1;
41 | Ns = length(sv);
42 |
43 | er = zeros(Ns,1);
44 | for i=1:Ns
45 | s = sv(i)
46 | B = phi.rbf(r,s); % half-sized system matrix
47 | a = rbfCentro.solveCentro(B,f,mu,safe);
48 | H = phi.rbf(re,s);
49 | fa = H*a;
50 | er(i) = norm(fa - fe, inf);
51 | end
52 |
53 | toc
54 | semilogy(sv,er,'g')
55 | warning
56 |
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/mdiExample.m:
--------------------------------------------------------------------------------
1 | % mdiExample
2 | %
3 | % 1d interpolation problem using extended precision and regulatization by
4 | % the method of diagonal increments.
5 |
6 | warning off
7 |
8 | phi = iqx();
9 | safe = false; % use Cholesky factorization
10 | S = 1.45:-0.025:0.05; % shape parameters
11 | Sn = length(S);
12 | M = 175;
13 | mp.Digits(34); N = mp('55'); pi = mp('pi');
14 | kappa = mp(zeros(Sn,1)); er = mp(zeros(Sn,1));
15 | kappa2 = mp(zeros(Sn,1)); er2 = mp(zeros(Sn,1));
16 | I = mp( eye(N) );
17 | mu = 10*mp.eps; % MDI regularization parameter
18 |
19 | gamma = 0.99;
20 | xc = (asin(-gamma*cos(pi*(0:N-1)/(N-1)))/asin(gamma))'; % boundary clustered centers
21 | r = rbfx.distanceMatrix1d(xc);
22 | x = linspace(-1,1,M)'; % evaluation points
23 | x = mp(x);
24 | re = rbfx.distanceMatrix1d(xc,x);
25 |
26 | f = exp(sin(pi*xc));
27 | fe = exp(sin(pi*x));
28 |
29 | for k = 1:Sn
30 | s = S(k);
31 | B = phi.rbf(r,s);
32 | kappa(k) = cond(B + mu*I);
33 | kappa2(k) = cond(B);
34 | a = rbfx.solve(B,f,mu,false); % MDI and Cholesky factoization
35 | H = phi.rbf(re,s);
36 | fa = H*a;
37 | er(k) = norm(fa - fe, inf);
38 |
39 | a2 = rbfx.solve(B,f,0,true); % no rugularization; use backslash
40 | % as Chol may fail without MDI
41 | fa2 = H*a2;
42 | er2(k) = norm(fa2 - fe, inf);
43 |
44 | end
45 |
46 | semilogy(S,kappa2,'b',S,kappa,'g--')
47 | xlabel('shape parameter'), ylabel('\kappa(B)')
48 |
49 | figure()
50 |
51 | semilogy(S,er2,'b',S,er,'g--')
52 | xlabel('shape parameter'), ylabel('|error|')
53 |
54 |
55 | warning on
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/mdiRegularization.m:
--------------------------------------------------------------------------------
1 | % mdiRegularization.m
2 | %
3 | % Interpolates the Franke function on scattered centers located in a domain
4 | % that is one-fourth of a circle. Compares the accuracy and condition number
5 | % of the system matrix over a range of shape parameter with and without
6 | % regularization by the method of diagonal increments.
7 |
8 | warning off, clear, home, close all
9 | mu = 2e-14;
10 |
11 | K = 1.5*sqrt(2);
12 | % open text files located in the /examples folder
13 | XC = dlmread('xc.txt',' '); xc = XC(:,1)/K; yc = XC(:,2)/K; % centers
14 | X = dlmread('x.txt',' '); x = X(:,1)/K; y = X(:,2)/K; % evaluation points
15 |
16 | N = length(xc); M = length(x);
17 |
18 | fn = F2d(); % Franke function
19 | f = fn.F(xc,yc);
20 | fe = fn.F(x,y);
21 |
22 | phi = iqx(); % IQ RBF
23 |
24 | [r, rx, ry] = rbfx.distanceMatrix2d(xc,yc);
25 | [re, rx, ry] = rbfx.distanceMatrix2d(xc,yc,x,y);
26 |
27 | S = 6:-0.1:0.2; Sn = length(S);
28 | kappa = zeros(Sn,1); er = zeros(Sn,1);
29 | kappa2 = zeros(Sn,1); er2 = zeros(Sn,1);
30 | I = eye(N);
31 |
32 | for k = 1:Sn
33 | s = S(k);
34 | B = phi.rbf(r,s); % system matrix
35 |
36 | kappa(k) = cond(B + mu*I);
37 | kappa2(k) = cond(B);
38 | a = rbfx.solve(B,f,mu,false); % regularized system solver
39 |
40 | H = phi.rbf(re,s);
41 | fa = H*a;
42 | er(k) = norm(fa - fe, inf);
43 |
44 | a2 = rbfx.solve(B,f,0,true); % no regularization
45 | fa2 = H*a2;
46 | er2(k) = norm(fa2 - fe, inf);
47 |
48 | end
49 |
50 | warning on
51 |
52 | semilogy(S,kappa2,'b--',S,kappa,'g')
53 | xlabel('shape parameter'), ylabel('\kappa(B)')
54 |
55 | figure()
56 |
57 | semilogy(S,er2,'b--',S,er,'g')
58 | xlabel('shape parameter'), ylabel('|error|')
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/poissonCentro.m:
--------------------------------------------------------------------------------
1 | % poissonCentro.m
2 | %
3 | % Solves a 2d steady PDE problem, a Poisson equation, on a circular domain
4 | % with Dirhclet boundary conditions, u_xx + u_yy = f(x,y).
5 | %
6 | % The problem is solved two ways: 1) standard algorithms, 2) centrosymmetric
7 | % algorithms. With N = 5000 the accuracy of the 2 approaches is the same
8 | % but the centrosymmetric approach is approximately 5 times faster and
9 | % requires half the storage.
10 |
11 |
12 | clear, home, close all
13 |
14 | CENTRO = false
15 | mu = 0;
16 | phi = iqx();
17 |
18 | %N = 2000; s = 2.0;
19 | N = 5001; s = 3.0;
20 |
21 |
22 | [tx, ty, Nb] = rbfCenters.circleUniformCenters(N,1);
23 |
24 | nh = Nb/2;
25 | xc(1:nh) = tx(N-Nb+1:N-nh); % half of boundary centers
26 | xc(nh+1:N-nh) = tx(1:N-Nb); % interior centers
27 | xc(N-nh+1:N) = tx(N-nh+1:N); % other half of boundary centers
28 |
29 | yc(1:nh) = ty(N-Nb+1:N-nh); % half of boundary centers
30 | yc(nh+1:N-nh) = ty(1:N-Nb); % interior centers
31 | yc(N-nh+1:N) = ty(N-nh+1:N); % other half of boundary centers
32 |
33 | [xc,yc] = rbfCentro.centroCenters(xc,yc,2,false);
34 | exact = 1 - xc + xc.*yc + 0.5*sin(pi*xc).*sin(pi*yc);
35 | f = -pi^2*sin(pi*xc).*sin(pi*yc);
36 |
37 | d = sqrt( xc.^2 + yc.^2 );
38 | I = find( d<(1+100*eps) & d>(1-100*eps)); % locate boundary points
39 | f(I) = exact(I);
40 |
41 |
42 | if CENTRO
43 |
44 | tic
45 | [r, rx, ry] = phi.distanceMatrix2d(xc(1:N/2),yc(1:N/2),xc,yc); % half-sized distance matrices
46 | B = phi.rbf(r,s); % half-sized system matrix
47 | H = phi.L(r, s); % Laplacian (half-sized)
48 | [kappaH, kappaL, kappaM] = rbfCentro.centroConditionNumber(H,mu)
49 |
50 | H(I,:) = B(I,:); % Dirichlet BCs
51 |
52 | a = rbfCentro.solveCentro(H,f,mu,true);
53 | [L,M] = rbfCentro.centroDecomposeMatrix(B,0);
54 | u = rbfCentro.centroMult(a,L,M,0);
55 |
56 | errorCentro = norm( u - exact, inf)
57 | toc
58 |
59 | else
60 |
61 | tic
62 | [r, rx, ry] = phi.distanceMatrix2d(xc,yc);
63 | B = phi.rbf(r,s);
64 | H = phi.L(r, s);
65 | kappaH = cond(H)
66 | H(I,:) = B(I,:);
67 |
68 | a = H\f;
69 | u = B*a;
70 |
71 | errorStandard = norm( u - exact, inf)
72 |
73 | toc
74 |
75 | rbfCentro.hasSymmetry(H); % check the full sized matrix for symmetry
76 |
77 | end
78 |
79 |
80 |
81 | % scatter(xc,yc,'b.')
82 | % hold on
83 | % scatter(xc(I),yc(I),'ro')
84 |
85 |
86 | % ---------- test for centrosymmetry with all boundary centers last -------
87 | % -> the matrix is not centrosymmetric
88 |
89 | % [xc, yc, Nb] = rbfCenters.circleUniformCenters(N,1);
90 | % d = sqrt( xc.^2 + yc.^2 );
91 | % I = find( d<(1+100*eps) & d>(1-100*eps));
92 | %
93 | % [r, rx, ry] = phi.distanceMatrix2d(xc,yc);
94 | % B = phi.rbf(r,s);
95 | % H = phi.L(r, s);
96 | % H(I,:) = B(I,:);
97 | % rbfCentro.hasSymmetry(H);
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/rbfInterpConvergence.m:
--------------------------------------------------------------------------------
1 | % % rbfInterpConvergence
2 | %
3 | % Convergence rate of a RBF interpolant with a fixed shape parameter and
4 | % increasing N. The convergence is geometric (also called spectral or
5 | % exponential) as long as the floating point system can handle the condition
6 | % number of the system matrix.
7 |
8 | warning off, clear, home, close all
9 |
10 | phi = iqx();
11 | mp.Digits(34);
12 | mu = 0; % MDI regularization parameter (no regularization)
13 | safe = true; % backslash rather than forcing Cholesky
14 | s = mp('2.0'); pi = mp('pi');
15 |
16 | M = 200;
17 | x = linspace(mp(-1),mp(1),M)'; % evaluation points
18 | fe = exp(sin(pi*x));
19 |
20 | Nv = mp(5:10:110);
21 | Ns = length(Nv);
22 | er = mp( zeros(Ns,1) );
23 |
24 | for k = 1:Ns
25 |
26 | N = Nv(k);
27 |
28 | xc = -cos(pi*mp(0:N-1)/(N-1))'; % boundary clustered centers
29 | r = rbfx.distanceMatrix1d(xc);
30 | f = exp(sin(pi*xc));
31 |
32 | B = phi.rbf(r,s);
33 | a = rbfx.solve(B,f,mu,safe); % expansion coefficients
34 |
35 | re = rbfx.distanceMatrix1d(xc,x);
36 | H = phi.rbf(re,s);
37 |
38 | fa = H*a;
39 | er(k) = norm(fa - fe, inf);
40 | end
41 |
42 |
43 | semilogy(Nv,er,'b*')
44 | xlabel('N'), ylabel('|error|')
45 | warning on
46 |
47 |
48 | figure()
49 | loglog(er(1:end-2),er(2:end-1), 'g')
50 |
51 | % rho approximately 1 implies geometric (spectral, or exponential) convergence
52 | rho = (log10(er(end-1)) - log10(er(end-2)))/(log10(er(end-2)) - log10(er(end-3)))
53 |
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/rbfInterpConvergenceB.m:
--------------------------------------------------------------------------------
1 | % rbfInterpConvergenceB
2 | %
3 | % Similiar to rbfInterpConvergence.m except that the number of centers N is
4 | % fixed and the shape parameter is decreasing. The convergence exponential
5 | % as long as the floating point system can handle the condition
6 | % number of the system matrix.
7 |
8 | warning off, clear, home, close all
9 |
10 |
11 | phi = iqx();
12 | mp.Digits(34);
13 | mu = 0; % MDI regularization parameter (no regularization)
14 | safe = true; % backslash rather than forcing Cholesky
15 | s = mp('2.0'); pi = mp('pi');
16 |
17 | N = mp('90');
18 | xc = -cos(pi*(0:N-1)/(N-1))'; % boundary clustered centers
19 | r = rbfx.distanceMatrix1d(xc);
20 | f = exp(sin(pi*xc));
21 |
22 | M = 200;
23 | x = mp( linspace(-1,1,M)' ); % evaluation points
24 | fe = exp(sin(pi*x));
25 |
26 | re = rbfx.distanceMatrix1d(xc,x);
27 |
28 | Sv = mp('10'):mp('-0.25'):mp('2.5');
29 | Ns = length(Sv);
30 | er = mp( zeros(Ns,1) );
31 |
32 | for k = 1:Ns
33 | s = Sv(k);
34 | B = phi.rbf(r,s);
35 | a = rbfx.solve(B,f,mu,safe);
36 | H = phi.rbf(re,s);
37 | fa = H*a;
38 | er(k) = norm(fa - fe, inf);
39 | end
40 |
41 |
42 | semilogy(Sv,er,'b*')
43 | xlabel('shape parameter'), ylabel('|error|')
44 | warning on
45 |
46 |
47 | figure()
48 | loglog(er(1:end-2),er(2:end-1), 'g')
49 |
50 | % rho approximately 1 implies exponential convergence
51 | rho = (log10(er(end-1)) - log10(er(end-2)))/(log10(er(end-2)) - log10(er(end-3)))
--------------------------------------------------------------------------------
/MRBFT-1.0/examples/variableShapeInterp1d.m:
--------------------------------------------------------------------------------
1 | % variableShapeInterp1d
2 |
3 | % Variable shape parameter versus constant shape. This is a typical example
4 | % in which the two approaches have system matrices with approximately the
5 | % same condition number, but the variable shape approach is several decimal
6 | % places more accurate.
7 |
8 |
9 | clear, home, warning off, format compact
10 |
11 | phi = gax();
12 | N = 44; M = 175;
13 | safe = true;
14 |
15 | %xc = linspace(-1,1,N)';
16 | xc = -cos((0:N-1)*pi/(N-1))'; % centers
17 | x = linspace(-1,1,M)';
18 |
19 | % problem 1: a very smooth function
20 | % f = exp(sin(pi*xc)); fe = exp(sin(pi*x)); fp = pi*cos(pi*xc).*exp(sin(pi*xc));
21 |
22 | % problem 2: a constant function
23 | f = ones(N,1); fe = ones(M,1); fp = zeros(N,1);
24 |
25 | r = phi.distanceMatrix1d(xc);
26 | re = phi.distanceMatrix1d(xc,x);
27 |
28 |
29 | % ------------- constant shape, interpolation -------------------
30 |
31 | s = 1.0;
32 | B = phi.rbf(r,s);
33 | kappa = cond(B);
34 | a = phi.solve(B,f,0,safe);
35 | H = phi.rbf(re,s);
36 | fa = H*a;
37 | er = norm(fa - fe, inf);
38 |
39 |
40 | % ------------- variable shape, interpolation -------------------
41 |
42 | sMin = 0.5;
43 | sMax = 1.5;
44 | opt = 3;
45 |
46 | [sn, sm] = phi.variableShape(sMin,sMax,opt,N,M);
47 |
48 | Bv = phi.rbf(r,sn);
49 | kappaV = cond(Bv);
50 | av = phi.solve(Bv,f,0,safe);
51 | Hv = phi.rbf(re,sm);
52 | fav = Hv*av;
53 | erV = norm(fav - fe, inf);
54 |
55 |
56 | % ------- constant shape, derivative ----------------------------
57 |
58 |
59 | H = phi.D1(r,s,r);
60 | fa = H*a;
61 | erd = norm(fa - fp, inf);
62 |
63 | % ------- variable shape, derivative ----------------------------
64 |
65 | Hv = phi.D1(r,sn,r);
66 | fav = Hv*av;
67 | erdv = norm(fav - fp, inf);
68 |
69 | fprintf('variable shape system matrix condition number: %1.2e \n',kappaV)
70 | fprintf('constant shape system matrix condition number: %1.2e \n\n',kappa)
71 |
72 | fprintf('variable shape interpolation error: %1.2e \n',erV)
73 | fprintf('constant shape interpolation error: %1.2e \n\n',er)
74 |
75 |
76 | fprintf('variable shape derivative error: %1.2e \n',erdv)
77 | fprintf('constant shape derivative error: %1.2e \n',erd)
--------------------------------------------------------------------------------
/MRBFT-1.0/functions/F1a.m:
--------------------------------------------------------------------------------
1 | classdef F1a < Function1d
2 |
3 | methods(Static)
4 | function obj = F1a(), obj@Function1d(); end
5 |
6 | function f = F(x), f = exp(sin(pi*x)); end % [-1,1]
7 |
8 | function f = x1(x)
9 | f = pi*cos(pi*x).*exp(sin(pi*x));
10 | end
11 |
12 | function f = x2(x)
13 | f =pi*pi*( -sin(pi*x) + cos(pi*x).^2 ).*exp(sin(pi*x));
14 | end
15 |
16 | function f = x3(x)
17 | f = -pi^3*(sin(pi*x) + 3).*exp(sin(pi*x)).*sin(pi*x).*cos(pi*x);
18 | end
19 |
20 | function f = x4(x)
21 | f = pi^4*(sin(pi*x).^4 + 6*sin(pi*x).^3 + 5*sin(pi*x).^2 - 5*sin(pi*x) - 3).*exp(sin(pi*x));
22 | end
23 |
24 | end % Static methods
25 |
26 | end % class
27 |
--------------------------------------------------------------------------------
/MRBFT-1.0/functions/F2a.m:
--------------------------------------------------------------------------------
1 | classdef F2a < Function2d
2 |
3 | methods(Static)
4 | function obj = F2a(), obj@Function2d(); end
5 |
6 | function f = F(x,y), f = x.^3.*log(1+y) + y./(1+x); end
7 |
8 | function f = x1(x,y), f = 3*x.^2.*log(y + 1) - y./(x + 1).^2; end
9 | function f = x2(x,y), f = 2*(3*x.*log(y + 1) + y./(x + 1).^3); end
10 | function f = x3(x,y), f = 6*(-y./(x + 1).^4 + log(y + 1)); end
11 | function f = x4(x,y), f = 24*y./(x + 1).^5; end
12 |
13 | function f = y1(x,y), f = (x.^3.*(x + 1) + y + 1)./((x + 1).*(y + 1)); end
14 | function f = y2(x,y), f = -x.^3./(y + 1).^2; end
15 | function f = y3(x,y), f = 2*x.^3./(y + 1).^3; end
16 | function f = y4(x,y), f = -6*x.^3./(y + 1).^4; end
17 |
18 | function f = G(x,y), f = (x.^3.*(x + 1).^2 + 3*x.^2.*(x + 1).^2.*(y + 1).*log(y + 1) - y.*(y + 1) + (x + 1).*(y + 1))./((x + 1).^2.*(y + 1)) ; end
19 | function f = L(x,y), f = -x.^3./(y + 1).^2 + 2*(3*x.*log(y + 1) + y./(x + 1).^3); end
20 | function f = B(x,y), f = -6*x.^3./(y + 1).^4 - 12*x./(y + 1).^2 + 24*y./(x + 1).^5; end
21 | function f = p12(x,y), f = -3*x.^2./(y + 1).^2; end
22 | function f = p21(x,y), f = 2*(3*x./(y + 1) + (x + 1).^(-3)); end
23 | function f = p22(x,y), f = -6*x./(y + 1).^2; end
24 |
25 | end % Static methods
26 |
27 | end % class
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/MRBFT-1.0/functions/F2b.m:
--------------------------------------------------------------------------------
1 | classdef F2b < Function2d
2 |
3 | methods(Static)
4 | function obj = F2b(), obj@Function2d(); end
5 |
6 | function f = F(x,y), f = exp(0.5*x + 0.2*y).*cos(x.*y); end
7 |
8 | function f = x1(x,y), f = 0.5*exp(0.5*x + 0.2*y).*( cos(x.*y) - 2*y.*sin(x.*y) ); end
9 | function f = x2(x,y), f = -0.25*exp(0.5*x + 0.2*y).*( (4*y.^2 - 1).*cos(x.*y) + 4*y.*sin(x.*y) ); end
10 | function f = x3(x,y), f = 0.125*exp(0.5*x + 0.2*y).*( (1 - 12*y.^2).*cos(x.*y) + 2*y.*(4*y.^2 - 3).*sin(x.*y) ); end
11 | function f = x4(x,y), f = 0.0625*exp(0.5*x + 0.2*y).*( (1 - 24*y.^2 + 16*y.^4).*cos(x.*y) + 8*y.*(-1 + 4*y.^2).*sin(x.*y) ); end
12 |
13 | function f = y1(x,y), f = 0.2*exp(0.5*x + 0.2*y).*( cos(x.*y) - 5*x.*sin(x.*y) ); end
14 | function f = y2(x,y), f = -0.04*exp(0.5*x + 0.2*y).*( (25*x.^2 - 1).*cos(x.*y) + 10*x.*sin(x.*y) ); end
15 | function f = y3(x,y), f = 0.008*exp(0.5*x + 0.2*y).*( (1 - 75*x.^2).*cos(x.*y) + 5*x.*(25*x.^2 - 3).*sin(x.*y) ); end
16 | function f = y4(x,y), f = 0.0016*exp(0.5*x + 0.2*y).*( (1 - 150*x.^2 + 625*y.^4).*cos(x.*y) + 20*x.*(-1 + 25*x.^2).*sin(x.*y) ); end
17 |
18 | function f = G(x,y), f = 0.1*exp(x/2 + y/5).*(7*cos(x.*y) - 10*(x + y).*sin(x.*y)); end
19 | function f = L(x,y), f = -0.01*exp(0.5*x + 0.2*y).*( (-29 + 100*x.^2 + 100*y.^2).*cos(x.*y) + 20*(2*x + 5*y).*sin(x.*y) ); end
20 |
21 | function f = B(x,y), f = 0.0001*exp(0.5*x + 0.2*y).*( (-39159 + 10000*x.^4 - 15800*y.^2 -16000*y + 10000*y.^4 - 8000*x.*(5+y) + 200*x.^2.*(100*y.^2 - 37)).*cos(x.*y) + ...
22 | 40*( 200*x.^3 + 500*x.^2.*y + x.*(-58 + 2000*y + 200*y.^2) + 5*(-40 - 29*y + 100*y.^3).*sin(x.*y) ) ); end
23 |
24 | function f = p12(x,y), f = -0.02*exp(0.5*x + 0.2*y).*( (-1 + 25*x.^2 + 20*x.*(5+y)).*cos(x.*y) + 2*(10 + 5*x + y - 25*x.^2.*y).*sin(x.*y) ); end
25 | function f = p21(x,y), f = -0.05*exp(0.5*x + 0.2*y).*( (-1 + 40*y + 20*x.*y + 4*y.^2).*cos(x.*y) + (20 + 5*x + 4*y - 20*x.*y.^2).*sin(x.*y) ); end
26 | function f = p22(x,y), f = 0.01*exp(0.5*x + 0.2*y).*( (-199 - 80*y - 4*y.^2 -200*x -40*x.*y - 25*x.^2 + 100*x.^2.*y.^2).*cos(x.*y) + 2*(50*x.^2.*y -2*(10+y) + 5*x.*(-1 + 40*y + 4*y.^2)).*sin(x.*y) ); end
27 |
28 | end % Static methods
29 |
30 | end % class
--------------------------------------------------------------------------------
/MRBFT-1.0/functions/F2c.m:
--------------------------------------------------------------------------------
1 | classdef F2c < Function2d
2 |
3 | methods(Static)
4 | function obj = F2c(), obj@Function2d(); end
5 |
6 | function f = F(x,y), f = exp(x.*y); end
7 |
8 | function f = x1(x,y), f = exp(x.*y).*y; end
9 | function f = x2(x,y), f = exp(x.*y).*y.^2; end
10 | function f = x3(x,y), f = exp(x.*y).*y.^3; end
11 | function f = x4(x,y), f = exp(x.*y).*y.^4; end
12 |
13 | function f = y1(x,y), f = exp(x.*y).*x; end
14 | function f = y2(x,y), f = exp(x.*y).*x.^2; end
15 | function f = y3(x,y), f = exp(x.*y).*x.^3; end
16 | function f = y4(x,y), f = exp(x.*y).*x.^4; end
17 |
18 | function f = G(x,y), f = exp(x.*y).*(x + y); end
19 | function f = L(x,y), f = exp(x.*y).*(x.^2 + y.^2); end
20 |
21 | function f = B(x,y), f = exp(x.*y).*(4 + x.^4 + y.^4 + 8*x.*y + 2*x.^2.*y.^2); end
22 |
23 | function f = p12(x,y), f = exp(x.*y).*x.*(2 + x.*y); end
24 | function f = p21(x,y), f = exp(x.*y).*y.*(2 + x.*y); end
25 | function f = p22(x,y), f = exp(x.*y).*(2 + 4*x.*y + x.^2.*y.^2); end
26 |
27 | end % Static methods
28 |
29 | end % class
--------------------------------------------------------------------------------
/MRBFT-1.0/functions/F2d.m:
--------------------------------------------------------------------------------
1 |
2 | % Franke function
3 | % NOT FULLY IMPLEMENTED
4 |
5 | classdef F2d < Function2d
6 |
7 | methods(Static)
8 | function obj = F2d(), obj@Function2d(); end
9 |
10 | function f = F(x,y), f = 0.75.*exp(-0.25.*(9.*x-2).^2 - 0.25.*(9.*y-2).^2) + 0.75.*exp(-((9.*x+1).^2)./49 - ((9.*y+1).^2)./10) + ...
11 | 0.5.*exp(-0.25.*(9.*x-7).^2-0.25.*(9.*y-3).^2) - 0.2.*exp(-(9.*x-4).^2-(9.*y-7).^2);
12 | end
13 |
14 | function f = x1(x,y), f = 1; end
15 | function f = x2(x,y), f = 1; end
16 | function f = x3(x,y), f = 1; end
17 | function f = x4(x,y), f = 1; end
18 |
19 | function f = y1(x,y), f = 1; end
20 | function f = y2(x,y), f = 1; end
21 | function f = y3(x,y), f = 1; end
22 | function f = y4(x,y), f = 1; end
23 |
24 | function f = G(x,y), f = (9.0/1960)*(784*exp(-(4 - 9*x).^2 - (7-9*y).^2).*(-11 + 9*x + 9*y) - ...
25 | 490*exp(-(1.0/4)*(7 - 9*x).^2 - (9/4.0)*(1 - 3*y).^2).*(-10 + 9*x + 9*y) - ...
26 | 735*exp(-2 + 9*x - (81*x.^2)/4.0 + 9*y - (81*y.^2)/4.0).*(-4 + 9*x + 9*y) - ...
27 | 6*exp(-(1.0/49)*(1 + 9*x).^2 - (1.0/10)*(1 + 9*y).^2).*(59 + 90*x + 441*y));
28 |
29 | end
30 | function f = L(x,y), f = 1; end
31 |
32 | function f = B(x,y), f = 1; end
33 |
34 | function f = p12(x,y), f = 1; end
35 | function f = p21(x,y), f = 1; end
36 | function f = p22(x,y), f = 1; end
37 |
38 | end % Static methods
39 |
40 | end % class
--------------------------------------------------------------------------------
/MRBFT-1.0/functions/Function1d.m:
--------------------------------------------------------------------------------
1 | classdef (Abstract) Function1d
2 |
3 | methods
4 | function obj = Function1d(), end % constructor
5 | end % methdds
6 |
7 |
8 | % Abstract methods used to define a common interface for all subclasses.
9 | % Abstract methods must be implemented by all subclasses.
10 |
11 | methods(Abstract = true, Static)
12 | v = F(x); % function definition
13 | d = x1(x); % 1st derivative
14 | d = x2(x); % 2nd derivative
15 | d = x3(x); % 3rd derivative
16 | d = x4(x); % 4th derivative
17 | end % abstract methods
18 |
19 | end % class
--------------------------------------------------------------------------------
/MRBFT-1.0/functions/Function2d.m:
--------------------------------------------------------------------------------
1 | classdef (Abstract) Function2d
2 |
3 | methods
4 | function obj = Function2d(), end % constructor
5 | end % methdds
6 |
7 |
8 | % Abstract methods used to define a common interface for all subclasses.
9 | % Abstract methods must be implemented by all subclasses.
10 |
11 | methods(Abstract = true, Static)
12 | v = F(x,y); % function definition
13 | d = x1(x,y); % 1st derivative wrt x
14 | d = x2(x,y); % 2nd derivative
15 | d = x3(x,y); % 3rd derivative
16 | d = x4(x,y); % 4th derivative
17 | d = y1(x,y); % 1st derivative wrt y
18 | d = y2(x,y); % 2nd derivative
19 | d = y3(x,y); % 3rd derivative
20 | d = y4(x,y); % 4th derivative
21 | d = G(x,y); % Gradient
22 | d = L(x,y); % Laplacian
23 | d = B(x,y); % Biharmonic
24 | d = p12(x,y); % mixed partials
25 | d = p21(x,y);
26 | d = p22(x,y)
27 | end % abstract methods
28 |
29 | end % class
--------------------------------------------------------------------------------
/MRBFT-1.0/gax.m:
--------------------------------------------------------------------------------
1 | % Matlab Radial Basis Function Toolkit (MRBFT)
2 | %
3 | % Project homepage: http://www.scottsarra.org/rbf/rbf.html
4 | % Contact e-mail: sarra@marshall.edu
5 | %
6 | % Copyright (c) 2016 Scott A. Sarra
7 | %
8 | % Licensing: MRBFT is under the GNU General Public License ("GPL").
9 | %
10 | % GNU General Public License ("GPL") copyright permissions statement:
11 | % **************************************************************************
12 | % This program is free software: you can redistribute it and/or modify
13 | % it under the terms of the GNU General Public License as published by
14 | % the Free Software Foundation, either version 3 of the License, or
15 | % (at your option) any later version.
16 | %
17 | % This program is distributed in the hope that it will be useful,
18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | % GNU General Public License for more details.
21 | %
22 | % You should have received a copy of the GNU General Public License
23 | % along with this program. If not, see .
24 |
25 | classdef gax < rbfx
26 | methods
27 | function obj = gax() % constructor
28 | obj@rbfx(); % call constructor of the superclass
29 | end
30 |
31 | function v = rbf(obj,r,s), v = exp( -(s.*r).^2 ); end
32 |
33 | function d = D1(obj,r,s,x), d = -2*x.*s.^2.*exp(-(s.*r).^2); end
34 |
35 | function d = D2(obj, r, s, x)
36 | d = 2.0*s.^2.*(2*x.*x.*s.^2 - 1.0).*exp(-(s.*r).^2);
37 | end
38 |
39 | function d = D3(obj, r, s, x)
40 | d = -4*exp(-(s.*r).^2).*x.*s.^4.*(2*s.^2.*x.^2 - 3);
41 | end
42 |
43 | function d = D4(obj, r, s, x)
44 | d = 4*exp(-(s.*r).^2).*s.^4.*(3 - 12*s.^2.*x.^2 + 4*s.^4.*x.^4);
45 | end
46 |
47 | function d = G(obj, r, s, x, y) % Gradient
48 | d = -2*exp(-(s.*r).^2).*s.^2.*(x + y);
49 | end
50 |
51 | function d = L(obj, r, s)
52 | d = 4*exp(-(s.*r).^2).*s.^2.*(r.^2.*s.^2 - 1.0);
53 | end
54 |
55 | function d = B(obj, r, s, x, y)
56 | d = 16*exp(-(s.*r).^2).*s.^4.*( 2 - 4*y.^2.*s.^2 + x.^4.*s.^4 + y.^4.*s.^4 + 2*x.^2.*s.^2.*( y.^2.*s.^2 - 2 ) );
57 | end
58 |
59 | % D12
60 | % mixed partial derivative
61 | % D_{xyy} d = D12( r, s, x, y )
62 | % or D_{yxx} d = D12( r, s, y, x)
63 | % depending on the order of the x and y arguments
64 |
65 | function d = D12(obj, r, s, x, y)
66 | d = exp(-(s.*r).^2).*x.*( 4*s.^4 - 8*y.^2.*s.^6 );
67 | end
68 |
69 | function d = D22(obj, r, s, x, y)
70 | d = 4*exp(-(s.*r).^2).*s.^4.*( 2*x.^2.*s.^2 - 1 ).*( 2*y.^2.*s.^2 - 1 );
71 | end
72 |
73 |
74 | end % public methods
75 |
76 | end % class
77 |
78 |
--------------------------------------------------------------------------------
/MRBFT-1.0/iqx.m:
--------------------------------------------------------------------------------
1 | % Matlab Radial Basis Function Toolkit (MRBFT)
2 | %
3 | % Project homepage: http://www.scottsarra.org/rbf/rbf.html
4 | % Contact e-mail: sarra@marshall.edu
5 | %
6 | % Copyright (c) 2016 Scott A. Sarra
7 | %
8 | % Licensing: MRBFT is under the GNU General Public License ("GPL").
9 | %
10 | % GNU General Public License ("GPL") copyright permissions statement:
11 | % **************************************************************************
12 | % This program is free software: you can redistribute it and/or modify
13 | % it under the terms of the GNU General Public License as published by
14 | % the Free Software Foundation, either version 3 of the License, or
15 | % (at your option) any later version.
16 | %
17 | % This program is distributed in the hope that it will be useful,
18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | % GNU General Public License for more details.
21 | %
22 | % You should have received a copy of the GNU General Public License
23 | % along with this program. If not, see .
24 |
25 |
26 | classdef iqx < rbfx
27 | methods
28 | function obj = iqx() % constructor
29 | obj@rbfx(); % call constructor of the superclass
30 | end
31 |
32 | function v = rbf(obj,r,s), v = 1./(1 + (s.*r).^2 ); end
33 |
34 | function d = D1(obj,r,s,x), d = -(2*x.*s.^2)./(1.0 + (s.*r).^2 ).^2; end
35 |
36 | function d = D2(obj, r, s, x)
37 | d = 2*s.^2.*(-r.^2.*s.^2 + 4*s.^2*x.^2 - 1)./(r.^2*s.^2 + 1).^3;
38 | %if nargin<5, y=0; end
39 | %d = ( -2*s.^2 + s.^4.*(6*x.^2 - 2*y.^2) )./(1.0 + (s.*r).^2 ).^3;
40 | end
41 |
42 | function d = D3(obj, r, s, x)
43 | d = (-48*x.^3.*s.^6)./(r.^2.*s.^2 + 1).^4 + (24*x.*s.^4)./(r.^2.*s.^2 + 1).^3;
44 | end
45 |
46 | function d = D4(obj, r, s, x)
47 | d = (384*x.^4.*s.^8)./(r.^2.*s.^2 + 1).^5 - (288*x.^2.*s.^6)./(r.^2.*s.^2 + 1).^4 + (24*s.^4)./(r.^2.*s.^2 + 1).^3;
48 | end
49 |
50 | function d = G(obj, r, s, x, y) % Gradient
51 | d = -2*s.^2.*(x + y)./(r.^2.*s.^2 + 1).^2;
52 | end
53 |
54 | function d = L(obj, r, s) % Laplacian
55 | d = 4*s.^2.*(r.^2.*s.^2 - 1)./(1 + (s.*r).^2 ).^3;
56 | end
57 |
58 | % x and y not used but required by the abstract function definition in the superclass
59 | function d = B(obj, r, s, x, y) % Biharmonic operator
60 | d = 64*( s.^4 - 4*r.^2.*s.^6 + r.^4.*s.^8 )./(1 + (s.*r).^2 ).^5;
61 | end
62 |
63 |
64 | % D12
65 | % mixed partial derivative
66 | % D_{xyy} d = D12( r, s, x, y )
67 | % or D_{yxx} d = D12( r, s, y, x)
68 | % depending on the order of the x and y arguments
69 |
70 | function d = D12(obj, r, s, x, y)
71 | d = 8*x.*s.^4.*(1 - 5*y.^2.*s.^2 + x.^2.*s.^2 )./(1 + (s.*r).^2 ).^4;
72 | end
73 |
74 | function d = D22(obj, r, s, x, y)
75 | d = -8*s.^4.*(-1 + 4*r.^2.*s.^2 + 5*(x.^4 + y.^4).*s.^4 - 38*x.^2.*y.^2.*s.^4 )./(1 + (s.*r).^2 ).^5;
76 | end
77 |
78 | end % methods
79 | end % class
80 |
--------------------------------------------------------------------------------
/MRBFT-1.0/rbfCenters.m:
--------------------------------------------------------------------------------
1 | % Matlab Radial Basis Function Toolkit (MRBFT)
2 | %
3 | % Project homepage: http://www.scottsarra.org/rbf/rbf.html
4 | % Contact e-mail: sarra@marshall.edu
5 | %
6 | % Copyright (c) 2016 Scott A. Sarra
7 | %
8 | % Licensing: MRBFT is under the GNU General Public License ("GPL").
9 | %
10 | % GNU General Public License ("GPL") copyright permissions statement:
11 | % **************************************************************************
12 | % This program is free software: you can redistribute it and/or modify
13 | % it under the terms of the GNU General Public License as published by
14 | % the Free Software Foundation, either version 3 of the License, or
15 | % (at your option) any later version.
16 | %
17 | % This program is distributed in the hope that it will be useful,
18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | % GNU General Public License for more details.
21 | %
22 | % You should have received a copy of the GNU General Public License
23 | % along with this program. If not, see .
24 |
25 | classdef rbfCenters
26 |
27 |
28 | % ----------------------------------------------------------------------------
29 | % ---------------- static methods --------------------------------------------
30 | % ----------------------------------------------------------------------------
31 |
32 | methods(Static)
33 |
34 | % Hammersley2d. Quasi-random Hammersley points on the unit square.
35 | %
36 | % inputs
37 | % N number of centers
38 | % plt logical variable: true -> plot centers, false -> no plot
39 | %
40 | % output
41 | % (x,y) center locations
42 | %
43 | % example usage:
44 | % 1) centroCenters.m
45 |
46 | function [x, y] = Hammersley2d(N,plt)
47 | if ~exist('plt','var'), plt = false; end
48 | x = zeros(N,1); y = zeros(N,1);
49 |
50 | for k = 0:N-1
51 | u = 0;
52 | p = 0.5;
53 | kk = k;
54 | while kk>0
55 | if bitand(kk,1)
56 | u = u + p;
57 | end
58 | p = 0.5*p;
59 | kk = bitshift(kk,-1);
60 | end
61 | v = (k + 0.5)/N;
62 | x(k+1) = u;
63 | y(k+1) = v;
64 | end
65 |
66 | if plt, scatter(x,y,'b.'); end
67 |
68 | end
69 |
70 |
71 | % Halton2d. Quasi-random Halton points on the unit square.
72 | %
73 | % inputs
74 | % N number of centers
75 | % plt logical variable: true -> plot centers, false -> no plot
76 | %
77 | % output
78 | % (x,y) center locations
79 |
80 | function [x, y] = Halton2d(N,plt)
81 | if ~exist('plt','var'), plt = false; end
82 | x = zeros(N,1);y = zeros(N,1);
83 |
84 | k = 0;
85 | while (k+1) ~= N
86 | u = 0;
87 | p = 0.5;
88 | kk = k;
89 |
90 | while kk>0
91 | if bitand(kk,1)
92 | u = u + p;
93 | end
94 | p = 0.5*p;
95 | kk = bitshift(kk,-1);
96 | end
97 |
98 | v = 0;
99 | p2 = 3.0; % prime2 which is taken to be 3
100 | ip = 1.0/p2;
101 | p = ip;
102 | kk = k;
103 |
104 | while kk>0
105 | a = rem(kk,p2);
106 | if a~=0, v = v + a*p; end
107 | p = p*ip;
108 | kk = floor(kk/p2);
109 | end
110 |
111 | x(k+1) = u;
112 | y(k+1) = v;
113 | k = k + 1;
114 | end
115 |
116 | if plt, scatter(x,y,'b.'); end
117 | end
118 |
119 | % squareCenters
120 | %
121 | % Quasirandom centers on a square [a,b]^2. The centers
122 | % are either based on a Hammersley or Halton sequence.
123 | %
124 | % inputs
125 | % N Number of centers in the covering square. The number of centers
126 | % returned is less than N.
127 | % cluster Logical variable for clustering option
128 | % ch 1 Halton
129 | % otherswise Hammersley
130 | % a, b square [a,b] x [a,b]
131 | % plt Logical variable for plotting option
132 | %
133 | % outputs
134 | % x, y center coordinates
135 |
136 | function [x, y] = squareCenters(N,a,b,cluster,ch,plt)
137 | if ~exist('plt','var'), plt = false; end
138 |
139 | if ch == 1
140 | [x, y] = rbfCenters.Halton2d(N,false);
141 | else
142 | [x, y] = rbfCenters.Hammersley2d(N,false);
143 | end
144 |
145 | x = 2*x - 1; % [0,1]^2 --> [-1,1]^2
146 | y = 2*y - 1;
147 |
148 | if cluster
149 | x = sin(0.5*pi*x); % cluster
150 | y = sin(0.5*pi*y);
151 | end
152 |
153 | x = 0.5*(b-a)*x + 0.5*(b + a); % [-1,1]^2 --> [a,b]^2
154 | y = 0.5*(b-a)*y + 0.5*(b + a);
155 |
156 | if plt, scatter(x,y,'b.'); end
157 |
158 | end
159 |
160 |
161 |
162 |
163 |
164 | % circleCenters - Quasirandom centers on a circle of radius R. The centers
165 | % are either based on a Hammersley or Halton sequence.
166 | % inputs
167 | % N Number of centers in the covering square. The number of centers
168 | % returned is less than N.
169 | % cluster Logical variable for clustering option
170 | % ch 1 Halton
171 | % otherswise Hammersley
172 | % R Radius of the circle
173 | % plt Logical variable for plotting option
174 | %
175 | % outputs
176 | % x, y center coordinates
177 | %
178 | % example usage: 1) interp2d_d.m
179 |
180 |
181 | function [x, y] = circleCenters(N,cluster,ch,R,plt)
182 | if ~exist('plt','var'), plt = false; end
183 | if ~exist('R','var'), R = 1; end
184 | if ch == 1
185 | [x, y] = rbfCenters.Halton2d(N);
186 | else
187 | [x, y] = rbfCenters.Hammersley2d(N);
188 | end
189 |
190 | x = 2*x - 1; % [0,1]^2 --> [-1,1]^2
191 | y = 2*y - 1;
192 | I = find( x.^2 + y.^2 <= 1 ); % restrict from square to circle
193 | x = x(I); y = y(I);
194 |
195 | if cluster
196 | [t,r] = cart2pol(x,y);
197 | r = sin(0.5*pi*r);
198 | [x,y] = pol2cart(t,r);
199 | end
200 |
201 | x = R*x; y = R*y; % adjust to have radius R
202 | if plt, scatter(x, y,'b.'); end
203 | end
204 |
205 |
206 |
207 |
208 |
209 | % circleUniformCenters - Uniform centers on a circle of radius R.
210 | %
211 | % inputs
212 | % N The number of centers returned
213 | % R Radius of the circle
214 | % plt Logical variable for plotting option
215 | %
216 | % outputs
217 | % x, y center coordinates
218 | % Nb The number of center located on the boundary which are in
219 | % the last Nb locations of the returned vector. Useful for
220 | % enforcing PDE boundary conditions. To plot boundary centers:
221 | % hold on
222 | % scatter( x(end-Nb+1:end), y(end-Nb+1:end),'ro')
223 | %
224 | % example usage:
225 | % 1) poissonCentro.m
226 |
227 | function [x,y, Nb] = circleUniformCenters(N,R,plt)
228 | if ~exist('plt','var'), plt = false; end
229 | if ~exist('R','var'), R = 1; end
230 | x(1) = 0; y(1) = 0;
231 | Ns = round( (sqrt(pi+4*(N-1)) - sqrt(pi)) /(2*sqrt(pi)) ); % number of circles
232 | K = pi*(Ns+1)/(N-1); % constant used in each loop
233 |
234 | for i = 1:Ns-1
235 | ri = i/Ns;
236 | ni = round(2*pi*ri/K); % number of points on circle i
237 | t = linspace(0, 2*pi, ni+1)'; t = t(1:ni);
238 |
239 | if mod(i,2)==0, % stagger the start of every other circle
240 | dt = t(2) - t(1);
241 | t = t + 0.5*dt;
242 | end
243 |
244 | x = [x; ri*cos(t)]; y = [y; ri*sin(t)];
245 | end
246 |
247 | Nb = N - length(x); % remaining points to be placed on the outter circle
248 | t = linspace(0, 2*pi, Nb + 1)'; t = t(1:Nb);
249 | x = [x; cos(t)]; y = [y; sin(t)];
250 | x = R*x; y = R*y; % adjust to have radius R
251 |
252 | if plt, scatter( x, y,'b.'); end
253 | end
254 |
255 |
256 | % -------------------------------------------------------------------------
257 |
258 |
259 | end % methods
260 |
261 |
262 | % ---------------------------------------------------------------------------
263 |
264 |
265 | end % classdef
266 |
--------------------------------------------------------------------------------
/MRBFT-1.0/rbfCentro.m:
--------------------------------------------------------------------------------
1 | % Matlab Radial Basis Function Toolkit (MRBFT)
2 | %
3 | % Project homepage: http://www.scottsarra.org/rbf/rbf.html
4 | % Contact e-mail: sarra@marshall.edu
5 | %
6 | % Copyright (c) 2016 Scott A. Sarra
7 | %
8 | % Licensing: MRBFT is under the GNU General Public License ("GPL").
9 | %
10 | % GNU General Public License ("GPL") copyright permissions statement:
11 | % **************************************************************************
12 | % This program is free software: you can redistribute it and/or modify
13 | % it under the terms of the GNU General Public License as published by
14 | % the Free Software Foundation, either version 3 of the License, or
15 | % (at your option) any later version.
16 | %
17 | % This program is distributed in the hope that it will be useful,
18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | % GNU General Public License for more details.
21 | %
22 | % You should have received a copy of the GNU General Public License
23 | % along with this program. If not, see .
24 |
25 | classdef rbfCentro
26 |
27 |
28 |
29 | % ----------------------------------------------------------------------------
30 | % ---------------- static methods --------------------------------------------
31 | % ----------------------------------------------------------------------------
32 |
33 | methods(Static)
34 |
35 | % ----------------------------------------------------------------------------
36 | % ------------ centro symmetric functions ------------------------------------
37 | % ----------------------------------------------------------------------------
38 |
39 |
40 | % Note: In testing a matrix for centro symmetry, the full N x N matrix constructed
41 | % by non-centrosymmetric algorithms must be used as extending an arbitrary
42 | % N x (N/2) matrix to an N x N matrix with rbfCentro.fullCentroMatrix will make
43 | % the full matrix centrosymmetric
44 |
45 |
46 | % isCentro and isSkewCentro - test a matrix for (skew)centrosymmetry
47 | %
48 | % input
49 | % B a N x N matrix
50 | %
51 | % output
52 | % s returns possibly zero or more probably a very small number, e.g. 1e-15,
53 | % for a N x N centrosymmetric input. otherwise, the return of a larger
54 | % number indicates the input matrix is
55 | % not centrosymmetric
56 |
57 |
58 | function c = isCentro(B)
59 | c = max( max( abs( B - fliplr(flipud(B)) ) ));
60 | end
61 |
62 |
63 | function c = isSkewCentro(B)
64 | c = max( max( abs( B + fliplr(flipud(B)) ) ));
65 | % c = max( max( abs(B + rot90(B,2) ) ) ); % works also
66 | end
67 |
68 | % hasSymmetry - tests a N x N matrix for both centrosymmetry and skew-centrosymmetry
69 | %
70 | % input
71 | % B a N x N matrix
72 | %
73 | % output
74 | % text message written to the Matlab command window
75 | %
76 | % example usage:
77 | % 1) isCentroTest.m
78 |
79 | function hasSymmetry(B)
80 | c1 = rbfCentro.isCentro(B);
81 | c2 = rbfCentro.isSkewCentro(B);
82 | if c1 < 100*eps
83 | disp('centrosymmeric')
84 | end
85 | if c2 < 100*eps
86 | disp('skew centrosymmeric')
87 | end
88 |
89 | if (c1 > 100*eps) && (c2 > 100*eps)
90 | fprintf('no centro symmetry (c = %4.1e, s = %4.1e)\n',c1,c2);
91 | end
92 |
93 | end
94 |
95 |
96 |
97 |
98 |
99 |
100 | % fullCentroMatrix
101 | %
102 | % Corrects a full centro matrix constructed with a standard algorithm so that is has
103 | % the correct symmetry or takes the left half of a matrix and expands it to have symmetry
104 | %
105 | % inputs
106 | % Dh either a N x N centro or skew-centro symmetric matrix
107 | % or the or the (N) x (N/2) left half of a such a matrix
108 | % skew 1 (or any positve odd integer) if skew-centro
109 | % 2 (or any positive even integer) if centro
110 | % N the number of rows of Dh (must be passed as a mp object for extended precision to work)
111 | % NOTE: N must be even
112 | %
113 | % outputs
114 | % D the full N x N matrix
115 | %
116 |
117 | function D = fullCentroMatrix(Dh,N,skew)
118 | n = N/2;
119 | D = zeros(N,N);
120 | D(:,1:n) = Dh(:,1:n); % left half
121 | D(1:n,n+1:N) = (-1)^(skew)*fliplr( flipud( D( n+1:N, 1:n) ) ); % D12
122 | D(n+1:N, n+1:N) = (-1)^(skew)*fliplr( flipud( D(1:n, 1:n) ) ); % D22
123 | end
124 |
125 | % -------------------------------------------------------------------------
126 |
127 | % solveCentro. Solves a centrosymmetric linear system Ba = f.
128 | %
129 | % inputs
130 | % B either a N x N centrosymmetric matrix (N must be even)
131 | % or the or the (N) x (N/2) left half of a centrosymmetric matrix
132 | % f N x 1 vector
133 | % mu MDI regularization parameter (mu=0 for no regularization)
134 | % safe true -> use backslash operator
135 | % false -> directly use Cholesky factorization
136 | %
137 | % outputs
138 | % a N x 1 solution of B a = f
139 | %
140 | % example usage: 1) poissonCentro.m
141 |
142 | function a = solveCentro(B,f,mu,safe)
143 | if ~exist('mu','var'), mu = 5e-15; end
144 | if ~exist('safe','var'), safe = true; end
145 |
146 | N = length(f);
147 | n = int64( N/2 );
148 |
149 | A = B(1:n,1:n); % B11
150 | t1 = flipud( B(n+1:N,1:n) ); % J*B21
151 | L = A - t1; % B11 - J*B21
152 | M = A + t1; % B11 + J*B21
153 |
154 | if mu>0
155 | L(1:n+1:end) = L(1:n+1:end) + mu; % L = L + mu*eye(n);
156 | M(1:n+1:end) = M(1:n+1:end) + mu;
157 | end
158 |
159 | b1 = f(1:n);
160 | t2 = flipud( f(n+1:N) ); % t2 = J*b2;
161 | b1p = b1 - t2;
162 | b2p = b1 + t2;
163 |
164 | if safe
165 | x1h = L\b1p;
166 | x2h = M\b2p;
167 | else
168 | L1 = chol(L,'lower');
169 | x1h = L1'\(L1\b1p);
170 |
171 | L2 = chol(M,'lower');
172 | x2h = L2'\(L2\b2p);
173 | end
174 |
175 | a = vertcat( 0.5*( x1h + x2h ), 0.5*flipud(x2h - x1h));
176 | end
177 |
178 |
179 | % -------------------------------------------------------------------------
180 |
181 | % centroDM. Constructs a RBF differentiation matrix.
182 | %
183 | % inputs
184 | % B N x (N/2) left half (or full N x N) centro system matrix.
185 | % Only the left half is used.
186 | % F N x (N/2) left half (or full N x N) derivative evaluation matrix.
187 | % Only the left half is used.
188 | % N Number of columns in B and F. Must be passed as mp('N') for
189 | % extended precision calculations. N must be even.
190 | % rho derivative order.
191 | % mu MDI regularization parameter (optional). Should be passed for
192 | % extended precisions as the default is for double precision.
193 | % safe true (backslash), false (Cholesky)
194 | %
195 | % outputs
196 | % D N x (N/2) left half of the DM. If the full DM is needed it can be
197 | % constructed with rbfCentro.fullCentroMatrix.
198 | %
199 | % example usage:
200 | % 1) diffusionReactionCentro.m
201 |
202 | function D = centroDM(B,F,N,rho,mu,safe)
203 | if ~exist('mu','var'), mu = 5e-15; end
204 | if ~exist('safe','var'), safe = true; end
205 |
206 | F = F*(-1)^(rho);
207 |
208 | n = N/2;
209 | D = zeros(N,n);
210 |
211 | A = B(1:n,1:n); % B11
212 | t1 = flipud( B(n+1:N,1:n) ); % J*B21
213 |
214 | L = A - t1;
215 | M = A + t1;
216 |
217 | if mu>0
218 | L(1:n+1:end) = L(1:n+1:end) + mu; % L = L + mu*eye(n);
219 | M(1:n+1:end) = M(1:n+1:end) + mu;
220 | end
221 |
222 | b1 = F(1:n,1:n);
223 | t2 = flipud( F(n+1:N,1:n) );
224 | b1p = b1 - t2;
225 | b2p = b1 + t2;
226 |
227 | if safe
228 | x1h = L\b1p;
229 | x2h = M\b2p;
230 | else
231 | L1 = chol(L,'lower');
232 | L2 = chol(M,'lower');
233 |
234 | x1h = L1'\( L1\b1p );
235 | x2h = L2'\( L2\b2p );
236 | end
237 |
238 | D(1:n,1:n) = 0.5*( x1h + x2h )'; % D11
239 | D(n+1:N,1:n) = (-1)^rho*fliplr( flipud( 0.5*flipud(x2h - x1h)' ) ); % D21
240 | end
241 |
242 | % ------ Condition number of a centrosymmetric system matrix ---------
243 |
244 | % inputs
245 | % B N x (N/2) left half (or full N x N) centro system matrix.
246 | % Only the left half is used.
247 | % mu MDI regularization parameter
248 | %
249 | % outputs:
250 | % kappaL
251 | % kappaM
252 | % kappaB 2-norm condition number of the matrix B
253 | %
254 | % example usage:
255 | % 1) diffusionReactionCentro.m, 2) poissonCentro.m
256 |
257 | function [kappaB, kappaL, kappaM] = centroConditionNumber(B,mu)
258 | [L,M] = rbfCentro.centroDecomposeMatrix(B,0);
259 | N = size(L);
260 | I = eye(N(2));
261 | sL = svd(2*(L + mu*I)); sM = svd(2*(M + mu*I));
262 | kappaL = max(sL)/min(sL); kappaM = max(sM)/min(sM);
263 | s = [sL; sM];
264 | kappaB = max(s)/min(s);
265 | end
266 |
267 | % NOTE: Mathematically, the following funtion that uses eigenvalues rather
268 | % than singular values is equivalent. However, if B is very ill-conitioned
269 | % for example cond(B)>10e15, the function using eig may return a complex
270 | % number as a condition number whereas the one using the SVD will always
271 | % return a real number.
272 |
273 |
274 | function kappa = centroConditionNumberEig(B,mu)
275 | [L,M] = rbfCentro.centroDecomposeMatrix(B,0);
276 | N = size(L); I = eye(N(2));
277 | ew = [eig(2*(L + mu*I)); eig(2*(M + mu*I))];
278 | kappa = max(ew)/min(ew);
279 | end
280 |
281 |
282 | % ---------- Parity Matrix Multiplication (N even) ------------------------
283 |
284 | % centroDecomposeMatrix. A (skew) centrosymmetric matrix is similar to a
285 | % block diagonal matric
286 | % [ L O ]
287 | % [ 0 M ]
288 | % Given D, this functions computes L and M which are used in condition
289 | % number, eigenvalue, and multiplication algorithsm.
290 | %
291 | % inputs
292 | % D either a N x N centrosymmetric matrix DM
293 | % or the or the (N) x (N/2) left half of a centrosymmetric matrix DM
294 | %
295 | % outputs
296 | % L/2 the even (N/2) x (N/2) DM
297 | % M/2 the odd (N/2) x (N/2) DM
298 | %
299 | % example usage:
300 | % 1) diffusionReactionCentro.m, 2) poissonCentro.m
301 |
302 | function [L,M] = centroDecomposeMatrix(D,rho)
303 | s = size(D);
304 | N = s(1); % number of rows
305 | N2 = N/2; % number of cols
306 |
307 | a = D(1:N2,1:N2); % B11
308 | b = (-1)^(rho+1)*flipud( D(N2+1:N,1:N2) ); % J*B21
309 |
310 | L = 0.5*( a - b); % L = 0.5*(B11 - J*B21) or Lh = 0.5*( B11 + J*B21)
311 | M = 0.5*( a + b); % M = 0.5*(B11 + J*B21) or Mh = 0.5*( B11 - J*B21 )
312 |
313 | end
314 |
315 | % centroMult. Matrix-vector multiplication with a (skew)centrosymmetric matrix
316 | %
317 | % inputs
318 | % u N x 1 vector
319 | % L the even (N/2) x (N/2) DM (L and M from rbfCentro.centroDecomposeMatrix)
320 | % M the odd (N/2) x (N/2) DM
321 | %
322 | % outputs
323 | % ua N x 1 vector that is the results of D*f
324 | %
325 | % example usage:
326 | % 1) diffusionReactionCentro.m, 2) poissonCentro.m
327 |
328 | function ua = centroMult(u,L,M,rho) % rho even, centro; rho odd, skew-centro
329 | u = u(:); N = length(u);
330 | N2 = N/2; k = 1:N2;
331 |
332 | t = flipud( u(N2+1:end) ); % decompose
333 | e = u(1:N2) + t; % xe_1
334 | o = u(1:N2) - t; % xo_1
335 |
336 | uae = L*e; % fe_1
337 | uao = M*o; % fo_1
338 |
339 | ua = zeros(N,1); % reconstruct
340 | ua(1:N2) = uae + uao; % f_1 = fe_1 + fo_1
341 | s1 = (-1)^(rho); s2 = (-1)^(rho+1);
342 | ua(N2+1:end) = flipud( s1*uae + s2*uao ); % f_2 = s1*J*fe_1 + s2*J*fo_1
343 |
344 |
345 | end
346 |
347 |
348 |
349 | % -------------------------------------------------------------------------
350 | % ------- centrosymmetric center distributions in 2d domains --------------
351 | % -------------------------------------------------------------------------
352 |
353 | % inputs
354 | % x, y centers covering an entire domain
355 | % symType 0 - y axis
356 | % 1 - x axis
357 | % 2 - origin
358 | % plt logical variable to plot centers
359 | %
360 | % outputs
361 | % xc, yc centrosymmetric center distribution
362 | %
363 | % example usage:
364 | % 1) diffusionReactionCentroDriver.m
365 |
366 | function [xc,yc] = centroCenters(x,y,symType,plt)
367 | x = x(:); y = y(:); % ensure column vectors
368 |
369 | if symType == 0
370 | I = find(x>0);
371 | xc = [x(I); flipud(-x(I))];
372 | yc = [y(I); flipud(y(I))];
373 | elseif symType == 1
374 | I = find(y>0);
375 | xc = [x(I); flipud(x(I))];
376 | yc = [y(I); flipud(-y(I))];
377 | elseif symType == 2
378 | I = find(y>x);
379 | xc = [x(I); flipud(-x(I))];
380 | yc = [y(I); flipud(-y(I))];
381 | end
382 |
383 | if plt, scatter( xc, yc,'b.'); end
384 |
385 | end
386 |
387 |
388 |
389 | % -------------- symmetric center distributions on a circle ---------------
390 |
391 | % centroCircle - centroCenters for the specific cace of a circle. Quasirandom
392 | % centers on a circle of radius R with centro placement. The centers
393 | % are either based on a Hammersley or Halton sequence.
394 | % inputs
395 | % N Number of centers in the covering square. The number of centers
396 | % returned is less than N.
397 | % cluster Logical variable for clustering option
398 | % ch 1 Halton
399 | % otherswise Hammersley
400 | % R Radius of the circle
401 | % plt Logical variable for plotting option
402 | %
403 | % outputs
404 | % xc, yc center coordinates
405 | %
406 | % example usage:
407 | % 1) isCentroTest.m
408 |
409 | function [xc,yc] = centroCircle(N,cluster,ch,R,plt)
410 | if ~exist('plt','var'), plt = false; end
411 | if ~exist('R','var'), R = 1; end
412 | [x, y] = rbfCenters.circleCenters(N,cluster,ch,R,plt);
413 | x = x(:); y = y(:);
414 |
415 | I = find(y>x); % extend about the origin
416 | xc = [x(I); flipud(-x(I))];
417 | yc = [y(I); flipud(-y(I))];
418 |
419 | if plt, scatter( xc, yc,'b.'); end
420 | end
421 |
422 |
423 | end % methods
424 |
425 |
426 |
427 | % ---------------------------------------------------------------------------
428 |
429 |
430 | end % classdef
431 |
--------------------------------------------------------------------------------
/MRBFT-1.0/rbfx.m:
--------------------------------------------------------------------------------
1 | % Matlab Radial Basis Function Toolkit (MRBFT)
2 | %
3 | % Project homepage: http://www.scottsarra.org/rbf/rbf.html
4 | % Contact e-mail: sarra@marshall.edu
5 | %
6 | % Copyright (c) 2016 Scott A. Sarra
7 | %
8 | % Licensing: MRBFT is under the GNU General Public License ("GPL").
9 | %
10 | % GNU General Public License ("GPL") copyright permissions statement:
11 | % **************************************************************************
12 | % This program is free software: you can redistribute it and/or modify
13 | % it under the terms of the GNU General Public License as published by
14 | % the Free Software Foundation, either version 3 of the License, or
15 | % (at your option) any later version.
16 | %
17 | % This program is distributed in the hope that it will be useful,
18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | % GNU General Public License for more details.
21 | %
22 | % You should have received a copy of the GNU General Public License
23 | % along with this program. If not, see .
24 |
25 |
26 | classdef rbfx
27 |
28 | % ----------------------------------------------------------------------------
29 | % ----------------------- Abstract methods------------------------------------
30 | % used to define a common interface for all subclasses
31 | % must be implemented by all subclasses.
32 | % ----------------------------------------------------------------------------
33 |
34 | methods(Abstract = true)
35 | v = rbf(obj,r,s); % RBF definition
36 | d = D1(obj,r,s,x); % first derivative wrt x
37 | d = D2(obj, r, s, x); % second derivative wrt x
38 | d = D3(obj, r, s, x); % third derivative wrt x
39 | d = D4(obj, r, s, x); % fourth derivative wrt x
40 | d = G(obj, r, s, x, y); % Gradient
41 | d = L(obj, r, s); % Laplacian
42 | d = B(obj, r, s, x, y); % Biharmonic operator
43 | d = D12(obj, r, s, x, y); % mixed partial derivative
44 | d = D22(obj, r, s, x, y); % mixed partial derivative
45 | end
46 |
47 | % ----------------------------------------------------------------------------
48 | % ---------------- static methods --------------------------------------------
49 | % ----------------------------------------------------------------------------
50 |
51 | methods(Static)
52 |
53 | % ----------------------------------------------------------------------------
54 | % ------------------ distance matrices ---------------------------------------
55 | % ----------------------------------------------------------------------------
56 |
57 | % distanceMatrix1d
58 | % inputs
59 | % xc N x 1 vector of centers
60 | % x M x 1 vector of evaluation points (optional)
61 | %
62 | % outputs
63 | % r signed distance matrix
64 | % N x N, r_{ij} = dist between center i and j if called as distanceMatrix1d(xc)
65 | % M x N, r_{ij} = dist between evaluation point i and center j if called as distanceMatrix1d(xc,x)
66 | % N x N/2 if called as r = phi.distanceMatrix1d(xc(1:N/2),xc)
67 | % returns the left half of the distance matrix needed
68 | % for a centro center distribution
69 | %
70 | % example usage:
71 | % 1) condVaccuracy.m, 2) rbfInterpConvergenceB.m
72 |
73 | function r = distanceMatrix1d(xc,x)
74 | xc = xc(:); % make sure xc is a column vector
75 | o = ones(1,length(xc));
76 | if nargin==1
77 | r = xc*o;
78 | r = r - r';
79 | else
80 | x = x(:);
81 | r = x*o - ones(length(x),1)*xc';
82 | end
83 | end
84 |
85 |
86 | % distanceMatrix2d
87 | %
88 | % inputs
89 | % xc N x 1 vectors of centers XC = (xc,yc)
90 | % yc
91 | % x M x 1 vectors of evaluation points X = (x,y) (optional)
92 | % y
93 | %
94 | % outputs
95 | % r signed distance matrix
96 | % N x N, r_{ij} = dist between center i and j if called as distanceMatrix1d(xc,yc)
97 | % M x N, r_{ij} = dist between evaluation point i and center j if called as distanceMatrix1d(xc,yc,x,y)
98 | % N x N/2 if called as r = phi.distanceMatrix1d(xc(1:N/2),yc(1:N/2),xc,yc)
99 | % returns the left half of the distance matrix needed
100 | % for a centro center distribution
101 | %
102 | % example usage:
103 | % 1) diffusionReactionCentro.m, 2) mdiRegularization.m, 3) poissonCentro.m
104 |
105 |
106 | function [r, rx, ry] = distanceMatrix2d(xc,yc,x,y)
107 | xc = xc(:); yc = yc(:);
108 | o = ones(1,length(xc));
109 | if nargin==2
110 | rx = (xc*o - (xc*o)');
111 | ry = (yc*o - (yc*o)');
112 | r = sqrt( rx.^2 + ry.^2 );
113 | else
114 | om = ones(length(x),1);
115 | x = x(:); y = y(:);
116 | rx = (x*o - om*xc');
117 | ry = (y*o - om*yc');
118 | r = sqrt( rx.^2 + ry.^2 );
119 | end
120 | end
121 |
122 |
123 | % distanceMatrix3d
124 | %
125 | % inputs
126 | % xc N x 1 vectors of centers XC = (xc,yc,zc)
127 | % yc
128 | % zc
129 | % x M x 1 vectors of evaluation points X = (x,y,z) (optional)
130 | % y
131 | % z
132 | %
133 | % outputs
134 | % r signed distance matrix
135 | % N x N, r_{ij} = dist between center i and j if called as distanceMatrix1d(xc,yc,zc)
136 | % M x N, r_{ij} = dist between evaluation point i and center j if called as distanceMatrix1d(xc,yc,zc,x,y,z)
137 | % N x N/2 if called as r = phi.distanceMatrix1d(xc(1:N/2),yc(1:N/2),zc(1:N/2),xc,yc,zc)
138 | % returns the left half of the distance matrix needed
139 | % for a centro center distribution
140 | %
141 | % example usage: 1) interp3d.m, 2) interp3dCentro.m
142 |
143 | function [r, rx, ry, rz] = distanceMatrix3d(xc,yc,zc,x,y,z)
144 | xc = xc(:); yc = yc(:); zc = zc(:);
145 | o = ones(1,length(xc));
146 | if nargin==3
147 | rx = (xc*o - (xc*o)');
148 | ry = (yc*o - (yc*o)');
149 | rz = (zc*o - (zc*o)');
150 | r = sqrt( rx.^2 + ry.^2 + rz.^2 );
151 | else
152 | om = ones(length(x),1);
153 | x = x(:); y = y(:); z = z(:);
154 | rx = (x*o - om*xc');
155 | ry = (y*o - om*yc');
156 | rz = (z*o - om*zc');
157 | r = sqrt( rx.^2 + ry.^2 + rz.^2 );
158 | end
159 | end
160 |
161 | % ----------------------------------------------------------------------------
162 | % ---------- regularized SPD linear system solvers ---------------------------
163 | % ----------------------------------------------------------------------------
164 |
165 | % solve - solves the SPD linear system B a = f for a with the option to regularize
166 | % by the method of diagonal increments (MDI)
167 | % inputs
168 | % B N x N symmetric positive definite (SPD) matrix
169 | % f N x 1 vector
170 | % mu (optional) MDI regularization parameter. Use mu = 0 for no regularization
171 | % safe true - uses backslash with error checking etc.
172 | % false - uses a Cholesky factorization. Faster, but it the matrix is
173 | % severely ill-conditioned and/or the regularization parameter is too
174 | % small the matrix may fail to be numerically SPD and the Cholesky
175 | % factorization will fail
176 | %
177 | % outputs
178 | % a N x 1 solution vector
179 | %
180 | % example usage:
181 | % 1) mdiExample.m, 2) mdiRegularization.m, 3) rbfInterpConvergence.m
182 |
183 | function a = solve(B,f,mu,safe)
184 | if ~exist('mu','var'), mu = 5e-15; end
185 | if ~exist('safe','var'), safe = true; end
186 |
187 | if mu>0
188 | N = length(f);
189 | B(1:N+1:end) = B(1:N+1:end) + mu; % C = B + mu*eye(N);
190 | end
191 |
192 | if safe
193 | a = B\f;
194 | else
195 | L = chol(B,'lower');
196 | a = L'\( L\f );
197 | end
198 | end
199 |
200 | % -------------------------------------------------------------------------
201 |
202 | % dm - forms the deriviative matrix D = H*inv(B) by solving the system D B = H for D
203 | % inputs
204 | % B N x N SPD system matrix
205 | % H N x N derivative evaluation matrix
206 | % mu (optional) MDI regularization parameter. Use mu = 0 for no regularization
207 | % safe true - uses backslash with error checking etc.
208 | % false - uses a Cholesky factorization. Faster, but if the matrix is
209 | % severely ill-conditioned and/or the regularization parameter is too
210 | % small the matrix may fail to be numerically SPD and the Cholesky
211 | % factorization will fail
212 | %
213 | % outputs
214 | % D N x N differentiation matrix
215 | %
216 | % example usage:
217 | % 1) diffusionReactionCentro.m
218 |
219 | function D = dm(B,H,mu,safe)
220 | if ~exist('mu','var'), mu = 5e-15; end
221 | if ~exist('safe','var'), safe = true; end
222 |
223 | if mu>0
224 | s = size(B); N = s(1);
225 | B(1:N+1:end) = B(1:N+1:end) + mu; % B = B + mu*eye(N);
226 | end
227 |
228 | if safe
229 | D = H/B;
230 | else
231 | L = chol(B,'lower');
232 | D = (L'\(L\H'))';
233 | end
234 | end
235 |
236 |
237 | % ----------------------------------------------------------------------------
238 | % -------------- variable shape parameters -----------------------------------
239 | % ----------------------------------------------------------------------------
240 |
241 | % variableShape
242 | %
243 | % example usage: variableShapeInterp1d.m
244 | %
245 | % inputs
246 | % sMin minimum value of the shape parameter
247 | % sMax maximum value of the shape parameter
248 | % N number of columns
249 | % M number of rows
250 | % opt 1, exponentially varying (Kansa)
251 | % Computers and Mathematics with Applications v. 24, no. 12, 1992.
252 | % 2, linearly varying
253 | % 3, randonly varying (Sarra and Sturgil)
254 | % Engineering Analysis with Boundary Elements, v. 33, p. 1239-1245, 2009.
255 | %
256 | % outputs
257 | % s1 N x N matrix with constant shapes in each column
258 | % call as, s1 = rbfx.variableShape(sMin,sMax,N)
259 | % s2 M x N matrix with constant shapes in each column
260 | % (optional, for interpolation evaluation matrix)
261 | % call as, [s1, s2] = rbfx.variableShape(sMin,sMax,N,M)
262 | %
263 | % example usage:
264 | % 1) variableShapeInterp1d.m
265 |
266 | function varargout = variableShape(sMin,sMax,opt,N,M)
267 | if nargin<5, M = []; end
268 | nOutputs = nargout;
269 | varargout = cell(1,nOutputs);
270 |
271 | if opt==1
272 | sMin = sMin^2; sMax = sMax^2;
273 | s = sqrt( sMin*(sMax/sMin).^((0:N-1)./(N-1)) );
274 | elseif opt==2
275 | s = sMin + ((sMax - sMin)/(N-1)).*(0:N-1);
276 | else
277 | s = rand(1,N);
278 | s = sMin + (sMax - sMin)*s;
279 | end
280 |
281 | if nOutputs==2
282 | varargout{1} = repmat(s,N,1);
283 | varargout{2} = repmat(s,M,1);
284 | else
285 | varargout{1} = repmat(s,N,1);
286 | end
287 | end
288 |
289 |
290 |
291 | % -------------------------------------------------------------------------
292 |
293 |
294 | end % methods
295 |
296 |
297 |
298 | % ---------------------------------------------------------------------------
299 |
300 |
301 | end % classdef
302 |
--------------------------------------------------------------------------------
/MRBFT-1.0/readme.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | The Radial Basis Function Toolbox (RBFT) is a collection of functions for implementing RBF interpolation methods and RBF methods for the numerical solution of PDEs on scattered centers located in complexly shaped domains. The toolbox is available in for Matlab (MRBFT) and a Python (PRBFT) version will be released in the future. The Matlab version uses the Multiprecision Computing Toolbox (http://www.advanpix.com/) to seamlessly implement extended precision floating point arithmetic in all RBFT routines.
4 |
5 | Comments, questions, bug reports, code requests, etc. can be sent to sarra@marshall.edu
6 |
7 |
8 | The functionality of the toolbox is organized via object oriented programming into several classes:
9 |
10 | rbfX - basic RBF method functionality
11 | gax - Gaussian RBF
12 | iqx - Inverse Quadratic RBF
13 | rbfCenters - center locations
14 | rbfCentro - reduced flop count and storage algorithms for RBF methods in symmetric domains.
15 | Functions - test functions and derivatives.
16 |
17 | The toolbox comes with a collection of scripts that demonstrate its usage, benchmark its performance, and verify that its algorithms produce the correct results. The scripts are located in the following folders.
18 |
19 | \examples
20 | \tests
21 | \benchmarks
22 |
23 |
24 | If the RBFT has been significant to a project that leads to an academic publication, please acknowledge that fact by citing the project. The academic reference for the RBFT is this paper (http://www.scottsarra.org/math/papers/sarraMRBFT.pdf). The BibTex entry for the paper is
25 |
26 | @Article{Sarra2016,
27 | Author = {S. A. Sarra},
28 | Title = {The {M}atlab Radial Basis Function Toolkit},
29 | Journal = {Journal of Open Research Software, under review},
30 | year = 2016,
31 | url = "www.scottsarra.org/rbf/rbf.html",
32 | }
33 |
34 | or in plain text:
35 |
36 | S. A. Sarra. The Matlab Radial Basis Function Toolkit. Under review, Journal of Open Research Software, 2016.
37 |
38 | Thank you!
39 |
40 |
41 |
--------------------------------------------------------------------------------
/MRBFT-1.0/tests/centroCondTest.m:
--------------------------------------------------------------------------------
1 | % centroCondTest
2 | %
3 | % Verifies the centrosymmetric condition number algorithm against the standard
4 | % algorithm. The two algorithms agree until the matrix becomes very
5 | % ill-conditioned. As expected there is a slight variation when
6 | % cond(B) > O(10^16)
7 |
8 | warning off
9 |
10 | phi = gax();
11 | N = 44;
12 | mu = 2e-16; % MDI regularization parameter
13 |
14 |
15 | %xc = linspace(-1,1,N)';
16 | xc = -cos((0:N-1)*pi/(N-1))'; % centers
17 |
18 | r = phi.distanceMatrix1d(xc(1:N/2),xc); % left half of system matrix
19 | rf = phi.distanceMatrix1d(xc,xc); % full system matrix
20 |
21 | sv = 10:-0.25:0.25;
22 | Ns = length(sv);
23 |
24 | cb = zeros(Ns,1); cbe = zeros(Ns,1); cf = zeros(Ns,1);
25 | for i=1:Ns
26 | s = sv(i);
27 | B = phi.rbf(r,s); % half-sized system matrix
28 | % cbe(i) = phi.centroConditionNumberEig(B,mu); % ill-conditioning leads to complex condition number
29 | [kappaB, kappaL, kappaM] = rbfCentro.centroConditionNumber(B,mu); % the SVD version is more stable
30 | cb(i) = kappaB;
31 | B = phi.rbf(rf,s); % full system matrix
32 | cf(i) = cond(B + mu*eye(N));
33 | end
34 |
35 |
36 | semilogy(sv,cb,'b',sv,cf,'g--')
37 | legend('cs kappa(B)','std kappa(B)')
38 | warning on
39 |
--------------------------------------------------------------------------------
/MRBFT-1.0/tests/centroSolveAccuracy.m:
--------------------------------------------------------------------------------
1 | % centroSolveAccuracy.m
2 | %
3 | % Compares the accuracy of centrosymmetric versus standard algorithms for solving
4 | % a centrosymmetic linear system. The linear system is the system for the RBF
5 | % expansion coefficients over a range of the shape parameter. The centrosymmetric
6 | % algorithm is slightly more accurate at most shape parameters and several
7 | % decimal places more accurate for several shape parameters.
8 |
9 | warning off
10 | phi = gax();
11 | N = 44;
12 | mu = 1e-15; % regularization parameter
13 | safe = false; % use Cholesky factorization
14 |
15 | %xc = linspace(-1,1,N)';
16 | xc = -cos((0:N-1)*pi/(N-1))'; % boundary clustered CGL centers
17 |
18 | r = phi.distanceMatrix1d(xc(1:N/2),xc); % left half of system matrix
19 | rf = phi.distanceMatrix1d(xc,xc); % full system matrix
20 |
21 | sv = 12:-0.25:3.0;
22 | Ns = length(sv);
23 | o = ones(N,1); % exact solution of the linear system
24 |
25 | er = zeros(Ns,1); er2 = zeros(Ns,1);
26 | for i=1:Ns
27 | s = sv(i);
28 |
29 | B = phi.rbf(r,s); % half-sized system matrix
30 | [L,M] = rbfCentro.centroDecomposeMatrix(B,0);
31 | f = rbfCentro.centroMult(o,L,M,0); % f = B*o, right side so that o is the exact solution
32 | a = rbfCentro.solveCentro(B,f,mu,safe);
33 | er(i) = norm(a - o, inf); % error from centrosymmetric solver
34 |
35 | B2 = phi.rbf(rf,s); % full-sized system matrix
36 | f = B2*o;
37 | a2 = phi.solve(B2,f,mu,safe);
38 | er2(i) = norm(a2 - o, inf); % error from solving the full system
39 |
40 | end
41 |
42 | semilogy(sv,er,'g*',sv,er2,'b*')
43 | legend('centrosymmetric','standard')
44 | xlabel('shape parameter'), ylabel('|error|')
45 | warning
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | % H NOT CENTRO
86 | %Nv = 8:2:16;
87 | %mu = 5e-14;
88 | %safe = false;
89 | %
90 | %Ns = length(Nv);
91 | %er = zeros(Ns,1); erc = zeros(Ns,1);
92 | %
93 | %for k = 1:Ns
94 | % N = Nv(k);
95 | % ae = ones(N,1);
96 | % H = hilb(N);
97 | % f = H*ae;
98 | % ac = rbfx.solveCentro(H,f,mu,safe);
99 | % erc(i) = norm(ac - ae, inf);
100 | % a = rbfx.solve(H,f,mu,safe);
101 | % er(i) = norm(a - ae, inf);
102 | %end
103 | %
104 | %semilogy(Nv,er,'b',Nv,erc,'g')
105 |
106 | %warning off
107 | %tic
108 | %
109 | %phi = gax();
110 | %N = 44;
111 | %M = 175;
112 | %mu = 2e-15;
113 | %safe = false;
114 | %
115 | %xc = linspace(-1,1,N)';
116 | %%xc = -cos((0:N-1)*pi/(N-1))'; % centers
117 | % x = linspace(-1,1,M)';
118 | %
119 | %%f = exp(sin(pi*xc));
120 | %%fe = exp(sin(pi*x));
121 | %
122 | %func = F1a();
123 | %f = func.F(xc);
124 | %fe = func.F(x);
125 | %
126 | %r = phi.distanceMatrix1d(xc(1:N/2),xc); % left half of system matrix
127 | %re = phi.distanceMatrix1d(xc,x);
128 | %
129 | %rf = phi.distanceMatrix1d(xc,xc); % full system matrix
130 | %
131 | %
132 | %sv = 2.5:-0.01:2.0;
133 | %Ns = length(sv);
134 | %
135 | %er = zeros(Ns,1); er2 = zeros(Ns,1); erL = zeros(Ns,1); erM = zeros(Ns,1);
136 | %for i=1:Ns
137 | % s = sv(i);
138 | % B = phi.rbf(r,s);
139 | % a = phi.solveCentro(B,f,mu,safe);
140 | % H = phi.rbf(re,s);
141 | % fa = H*a;
142 | % er(i) = norm(fa - fe, inf); % interpolation error
143 | % %[kappaB, kappaL, kappaM, ews] = phi.centroSystemMatrixCond(B,mu); % system matrix condition number
144 | % %er(i) = kappaB; erL(i) = kappaL; erM(i) = kappaM;
145 | %
146 | %% B = phi.fullCentroMatrix(B,N,0);
147 | % B2 = phi.rbf(rf,s);
148 | % a2 = phi.solve(B2,f,mu,safe);
149 | % fa2 = H*a2;
150 | % er2(i) = norm(fa2 - fe, inf);
151 | %
152 | %% er2(i) = cond(B + mu*eye(N));
153 | %end
154 | %
155 | %toc
156 | %semilogy(sv,er,'g',sv,er2,'b')
157 | %warning
158 | %min(er)
--------------------------------------------------------------------------------
/MRBFT-1.0/tests/isCentroTest.m:
--------------------------------------------------------------------------------
1 | % isCentroTest.m
2 | %
3 | % Depending on how the centers were extended to be symmetric, RBF
4 | % differentiation matrices will have a (skew) centrosymmetric structure.
5 | % The following reference can be consulted for details:
6 | % "Radial Basis Function Methods - the case of symmetric domains."
7 | % Under review, Numerical Methods for Partial Differential Equations, 2016.
8 |
9 | phi = iqx();
10 |
11 | s = 10; % shape parameter
12 |
13 | % symType 0 - y axis
14 | % 1 - x axis
15 | % 2 - origin -> all order derivative have correct symmetry
16 |
17 | symType = 2;
18 |
19 | %[xc,yc] = rbfCentro.centroCircle(500,true,0,1,false); % uses origin sym
20 |
21 |
22 | [x, y] = rbfCenters.circleCenters(500,true,0,1,false);
23 | [xc,yc] = rbfCentro.centroCenters(x,y,symType,true);
24 |
25 |
26 | [r, rx, ry] = rbfx.distanceMatrix2d(xc,yc);
27 |
28 | H1 = phi.D1(r,s,rx);
29 | H2 = phi.D2(r,s,rx);
30 | H3 = phi.D3(r,s,rx);
31 | H4 = phi.D4(r,s,rx);
32 | G = phi.G(r, s, rx, ry);
33 | L = phi.L(r, s);
34 | B = phi.B(r, s, rx, ry) ;
35 | H12 = phi.D12(r, s, rx, ry);
36 | H22 = phi.D22(r, s, rx, ry);
37 |
38 | disp(' ')
39 | fprintf('D1: '); rbfCentro.hasSymmetry(H1);
40 | fprintf('D2: '); rbfCentro.hasSymmetry(H2);
41 | fprintf('D3: '); rbfCentro.hasSymmetry(H3);
42 | fprintf('D4: '); rbfCentro.hasSymmetry(H4);
43 |
44 | fprintf('gradient: '); rbfCentro.hasSymmetry(G);
45 | fprintf('Laplacian: '); rbfCentro.hasSymmetry(L);
46 | fprintf('Biharmonic: '); rbfCentro.hasSymmetry(B);
47 |
48 | fprintf('mixed partial 12: '); rbfCentro.hasSymmetry(H12);
49 | fprintf('mixed partial 22: '); rbfCentro.hasSymmetry(H2);
--------------------------------------------------------------------------------
/MRBFT-1.0/tests/rbfDerivativeTest.m:
--------------------------------------------------------------------------------
1 | % rbfDerivativeTest
2 | %
3 | % Tests all derivative approximation methods of the iqx and gax classes
4 | % using both double and quadruple precision
5 |
6 |
7 | % ---------- output of the four tests -------------------
8 |
9 |
10 | % OUTPUT OF TEST 1
11 | %dx error = 6.83e-09
12 | %dxx error = 1.75e-07
13 | %dxxx error = 8.82e-06
14 | %dxxxx error = 6.47e-04
15 | %dy error = 7.34e-09
16 | %dyy error = 1.24e-07
17 | %dyyy error = 8.73e-06
18 | %dyyyy error = 8.38e-04
19 | %gradient error = 1.05e-08
20 | %Laplacian error = 1.68e-07
21 | %biharmonic error = 1.36e-03
22 | %dx1y2 error = 4.60e-06
23 | %dx2y1 error = 4.43e-06
24 | %dx2y2 error = 2.94e-04
25 |
26 | % ---------------------------
27 |
28 | % OUTPUT OF TEST 2
29 | %dx error = 9.44e-12
30 | %dxx error = 3.03e-10
31 | %dxxx error = 2.12e-08
32 | %dxxxx error = 5.31e-06
33 | %dy error = 1.06e-11
34 | %dyy error = 3.27e-10
35 | %dyyy error = 6.19e-08
36 | %dyyyy error = 1.27e-05
37 | %gradient error = 1.86e-11
38 | %Laplacian error = 2.74e-10
39 | %biharmonic error = 1.95e-05
40 | %dx1y2 error = 3.00e-08
41 | %dx2y1 error = 2.13e-08
42 | %dx2y2 error = 4.23e-06
43 |
44 | % ----------------------------
45 |
46 | % OUTPUT OF TEST 3
47 | %dx error = 3.40e-05
48 | %dxx error = 5.92e-03
49 | %dxxx error = 7.53e-01
50 | %dxxxx error = 7.11e+01
51 | %dy error = 4.30e-05
52 | %dyy error = 6.07e-03
53 | %dyyy error = 7.38e-01
54 | %dyyyy error = 6.68e+01
55 | %gradient error = 5.74e-05
56 | %Laplacian error = 6.86e-03
57 | %biharmonic error = 1.14e+02
58 | %dx1y2 error = 3.99e-01
59 | %dx2y1 error = 3.00e-01
60 | %dx2y2 error = 2.55e+01
61 |
62 | % ---------------------------
63 |
64 | % OUTPUT OF TEST 4
65 | %dx error = 1.04e-04
66 | %dxx error = 2.79e-03
67 | %dxxx error = 3.40e-01
68 | %dxxxx error = 4.01e+01
69 | %dy error = 9.49e-05
70 | %dyy error = 3.11e-03
71 | %dyyy error = 3.77e-01
72 | %dyyyy error = 2.98e+01
73 | %gradient error = 1.40e-04
74 | %Laplacian error = 3.25e-03
75 | %biharmonic error = 6.00e+01
76 | %dx1y2 error = 1.32e-01
77 | %dx2y1 error = 1.91e-01
78 | %dx2y2 error = 1.34e+01
79 |
80 | % ----------------------------------------------------------------------
81 |
82 | clear, home, format compact
83 |
84 | TESTNUMBER = 4;
85 |
86 | if TESTNUMBER == 1
87 | % test 1, IQ with quadruple precision
88 | phi = iqx();
89 | mp.Digits(34); s = mp('1.2'); N = mp('2000');
90 | elseif TESTNUMBER == 2
91 | % test 2, GA with quadruple precision
92 | phi = gax();
93 | mp.Digits(34); s = mp('3.5'); N = mp('2000');
94 | elseif TESTNUMBER == 3
95 | % test 3, GA with double precision
96 | phi = gax();
97 | s = 4.5; N = 2000;
98 | else
99 | % test 4, IQ with double precision
100 | phi = iqx();
101 | s = 2.35; N = 2000;
102 | end
103 |
104 | nCh = inf; % norm choice
105 | G = F2c;
106 |
107 | [x, y] = rbfCenters.circleCenters(N,true,1,1,false);
108 | f = G.F(x,y);
109 |
110 | [r, rx, ry] = phi.distanceMatrix2d(x,y);
111 | B = phi.rbf(r,s);
112 |
113 | mu = 0;
114 | safe = true; % use mldivide rather than Cholesky directly
115 | a = rbfx.solve(B,f,mu,safe);
116 |
117 |
118 | H = phi.D1(r,s,rx);
119 | fx = H*a;
120 | fprintf('dx error = %4.2e\n',norm(fx - G.x1(x,y), nCh));
121 |
122 | H = phi.D2(r,s,rx);
123 | fxx = H*a;
124 | fprintf('dxx error = %4.2e\n',norm(fxx - G.x2(x,y), nCh));
125 |
126 | H = phi.D3(r,s,rx);
127 | fxxx = H*a;
128 | fprintf('dxxx error = %4.2e\n',norm(fxxx - G.x3(x,y), nCh));
129 |
130 | H = phi.D4(r,s,rx);
131 | fxxxx = H*a;
132 | fprintf('dxxxx error = %4.2e\n',norm(fxxxx - G.x4(x,y), nCh));
133 |
134 |
135 | H = phi.D1(r,s,ry);
136 | fy = H*a;
137 | fprintf('dy error = %4.2e\n',norm(fy - G.y1(x,y), nCh));
138 |
139 | H = phi.D2(r,s,ry);
140 | fyy = H*a;
141 | fprintf('dyy error = %4.2e\n',norm(fyy - G.y2(x,y), nCh));
142 |
143 | H = phi.D3(r,s,ry);
144 | fyyy = H*a;
145 | fprintf('dyyy error = %4.2e\n',norm(fyyy - G.y3(x,y), nCh));
146 |
147 | H = phi.D4(r,s,ry);
148 | fyyyy = H*a;
149 | fprintf('dyyyy error = %4.2e\n',norm(fyyyy - G.y4(x,y), nCh));
150 |
151 |
152 | H = phi.G(r,s,rx, ry);
153 | fG = H*a;
154 | fprintf('gradient error = %4.2e\n',norm(fG - G.G(x,y), nCh));
155 |
156 | H = phi.L(r,s);
157 | fL = H*a;
158 | fprintf('Laplacian error = %4.2e\n',norm(fL- G.L(x,y), nCh));
159 |
160 | H = phi.B(r,s,rx, ry);
161 | fB = H*a;
162 | fprintf('biharmonic error = %4.2e\n',norm(fB - G.B(x,y), nCh));
163 |
164 | H = phi.D12(r,s,rx,ry);
165 | f12 = H*a;
166 | fprintf('dx1y2 error = %4.2e\n',norm(f12- G.p12(x,y), nCh));
167 |
168 | H = phi.D12(r,s,ry,rx);
169 | f21 = H*a;
170 | fprintf('dx2y1 error = %4.2e\n',norm(f21- G.p21(x,y), nCh));
171 |
172 | H = phi.D22(r,s,ry,rx);
173 | f22 = H*a;
174 | fprintf('dx2y2 error = %4.2e\n',norm(f22- G.p22(x,y), nCh));
--------------------------------------------------------------------------------