Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • antik/gsll
  • mvukovic/gsll
  • ssimsek/gsll
  • ajuan/gsll
4 results
Show changes
Commits on Source (95)
Showing
with 991 additions and 387 deletions
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
gsll
Copyright (C) 2018 antik
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
gsll Copyright (C) 2018 antik
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
;; Define generic operators for GSL functions
;; Liam Healy 2011-01-01 09:51:47EST linear-algebra.lisp
;; Time-stamp: <2011-01-01 11:48:49EST linear-algebra.lisp>
;; Copyright 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :antik)
(defmethod *i ((a grid:foreign-array) (b grid:foreign-array))
(gsl:matrix-product a b))
(defmethod *i ((a grid:foreign-array) (b number))
(gsl:scale b a))
(defmethod *i ((a number) (b grid:foreign-array))
(gsl:scale a b))
(defmethod /i ((a grid:foreign-array) (b number))
(gsl:scale (cl:/ b) a))
(defmethod +i ((a grid:foreign-array) (b grid:foreign-array))
(gsl:elt+ a b))
(defmethod +i ((a grid:foreign-array) (b number))
(gsl:elt+ a b))
(defmethod +i ((a number) (b grid:foreign-array))
(gsl:elt+ b a))
(defmethod -i ((a grid:foreign-array) (b grid:foreign-array))
(gsl:elt- a b))
(defmethod -i ((a grid:foreign-array) (b number))
(gsl:elt+ a (cl:- b)))
(defmethod -i ((a number) (b grid:foreign-array))
(gsl:elt+ (- b) a))
(defmethod expt ((a grid:matrix) (b integer))
(cond ((= 1 b) a)
((plusp b) ; use addition-chain exponentiation
(* a (expt a (1- b))))
((minusp b)
(expt (invert-matrix a) (- b)))
;; zero exponent; need to figure out non-square matrix
(t (grid:identity-matrix (grid:dim0 a)))))
;;; Invert a matrix using LU
(export 'invert-matrix)
(defun invert-matrix (mat)
"Invert the matrix."
(let* ((dim (grid:dim0 mat))
(per (gsl:make-permutation dim))
(inv (grid:make-foreign-array 'double-float :dimensions (list dim dim))))
(gsl:lu-decomposition mat per)
(gsl:lu-invert mat per inv)))
#|
;;; Examples and unit test
;;; These are direct tests of matrix inversion
(save-test
lu
(grid:copy-to
(invert-matrix
(grid:make-foreign-array 'double-float
:dimensions '(2 2)
:initial-contents '(1.0d0 2.0d0 3.0d0 4.0d0)))))
(LISP-UNIT:ASSERT-NUMERICAL-EQUAL
(LIST
#2A((-1.9999999999999998d0 1.0d0)
(1.4999999999999998d0 -0.49999999999999994d0)))
(MULTIPLE-VALUE-LIST
(GRID:COPY-TO
(INVERT-MATRIX
(GRID:MAKE-FOREIGN-ARRAY 'DOUBLE-FLOAT :DIMENSIONS '(2 2)
:INITIAL-CONTENTS
'((1.0d0 2.0d0) (3.0d0 4.0d0)))))))
|#
;; Basis splines.
;; Liam Healy 2008-02-18 14:43:20EST basis-splines.lisp
;; Time-stamp: <2011-01-13 10:24:59EST basis-splines.lisp>
;; Time-stamp: <2016-06-15 23:07:19EDT basis-splines.lisp>
;;
;; Copyright 2008, 2009, 2011 Liam M. Healy
;; Copyright 2008, 2009, 2011, 2012, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -25,7 +25,7 @@
;;; Should be subclass of interpolation?
(defmobject basis-spline "gsl_bspline"
((order sizet) (number-of-breakpoints sizet))
((order :sizet) (number-of-breakpoints :sizet))
"basis spline"
:gsl-version (1 9)
:documentation ; FDL
......@@ -79,30 +79,37 @@
(defmfun number-of-coefficients (bspline)
"gsl_bspline_ncoeffs"
(((mpointer bspline) :pointer))
:c-return sizet
:c-return :sizet
:gsl-version (1 9))
(defmfun order ((bspline basis-spline))
"gsl_bspline_order"
(((mpointer bspline) :pointer))
:definition :method
:c-return sizet
:c-return :sizet
:gsl-version (1 9))
(defmfun number-of-breakpoints (bspline)
"gsl_bspline_nbreak"
(((mpointer bspline) :pointer))
:c-return sizet
:c-return :sizet
:gsl-version (1 9)
:documentation "The number of breakpoints of the basis spline bspline.")
(defmfun breakpoint (i bspline)
"gsl_bspline_breakpoint"
((i sizet) ((mpointer bspline) :pointer))
((i :sizet) ((mpointer bspline) :pointer))
:c-return :double
:gsl-version (1 9)
:documentation "The ith breakpoint of the basis spline bspline.")
(defmfun greville-abscissa (i bspline)
"gsl_bspline_greville_abscissa"
((i :sizet) ((mpointer bspline) :pointer))
:c-return :double
:gsl-version (1 13)
:documentation "Returns the location of the @math{i}-th Greville abscissa for the given B-spline basis. For the ill-defined case when @math{k=1}, the implementation chooses to return breakpoint interval midpoints.")
;;; Examples and unit test
(defun bspline-example (&optional (ncoeffs 8))
......@@ -125,18 +132,18 @@
(let* ((xi (coerce (* i (/ 15 (1- ndata))) 'double-float))
(yi (+ (* (cos xi) (exp (* -0.1d0 xi)))
(sample rng :gaussian :sigma sigma))))
(setf (grid:gref x i) xi
(grid:gref y i) yi
(grid:gref w i) (/ (expt sigma 2)))))
(setf (grid:aref x i) xi
(grid:aref y i) yi
(grid:aref w i) (/ (expt sigma 2)))))
;; Uniform breakpoints [0, 15]
(uniform-knots 0.0d0 15.0d0 bw)
;; Fit matrix
(dotimes (i ndata)
;; Compute B_j
(evaluate bw (grid:gref x i) :b B)
(evaluate bw (grid:aref x i) :b B)
;; Fill in row i of X
(dotimes (j ncoeffs)
(setf (grid:gref Xmatrix i j) (grid:gref B j))))
(setf (grid:aref Xmatrix i j) (grid:aref B j))))
;; Do the fit
(linear-mfit Xmatrix y c w nil cov mw)
;; Return the smoothed curve
......
;; CFFI-Grovel definitions for unix systems.
;; Liam Healy 2009-06-06 09:32:30EDT monte-carlo-structs.lisp
;; Time-stamp: <2010-05-23 11:36:42EDT monte-carlo-structs.lisp>
;; Time-stamp: <2016-06-12 16:33:01EDT monte-carlo-structs.lisp>
;;
;; Copyright 2009, 2010 Liam M. Healy
;; Copyright 2009, 2010, 2012, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -31,18 +31,18 @@
(include "gsl/gsl_monte_plain.h")
(cstruct plain-state "gsl_monte_plain_state"
(dim "dim" :type sizet)
(dim "dim" :type :sizet)
(x "x" :type :pointer))
(include "gsl/gsl_monte_miser.h")
(cstruct miser-state "gsl_monte_miser_state"
(min-calls "min_calls" :type sizet)
(min-calls-per-bisection "min_calls_per_bisection" :type sizet)
(min-calls "min_calls" :type :sizet)
(min-calls-per-bisection "min_calls_per_bisection" :type :sizet)
(dither "dither" :type :double)
(estimate-frac "estimate_frac" :type :double)
(alpha "alpha" :type :double)
(dim "dim" :type sizet)
(dim "dim" :type :sizet)
(estimate-style "estimate_style" :type :int)
(depth "depth" :type :int)
(verbose "verbose" :type :int)
......@@ -61,12 +61,20 @@
(hits-l "hits_l" :type :pointer)
(hits-r "hits_r" :type :pointer))
;;; Added with GSL 1.13
(cstruct miser-params "gsl_monte_miser_params"
(function-call-variance-estimation-fraction "estimate_frac" :type :double)
(minimum-number-of-calls-for-variance-estimation "min_calls" :type :sizet)
(minimum-calls-per-bisection "min_calls_per_bisection" :type :sizet)
(alpha "alpha" :type :double)
(dither "dither" :type :double))
(include "gsl/gsl_monte_vegas.h")
(cstruct vegas-state "gsl_monte_vegas_state"
;; grid
(dim "dim" :type sizet)
(bins-max "bins_max" :type sizet)
(dim "dim" :type :sizet)
(bins-max "bins_max" :type :sizet)
(bins "bins" :type :uint) ; uint
(boxes "boxes" :type :uint) ; these are both counted along the axes
(xi "xi" :type :pointer)
......@@ -84,3 +92,19 @@
(verbose "verbose" :type :int)
(iterations "iterations" :type :uint)
(stage "stage" :type :int))
;;; Added with GSL 1.13
(cenum monte-carlo-vegas-mode
((:stratified "GSL_VEGAS_MODE_STRATIFIED"))
((:importance-only "GSL_VEGAS_MODE_IMPORTANCE_ONLY"))
((:importance "GSL_VEGAS_MODE_IMPORTANCE")))
;;; Added with GSL 1.13
(cstruct vegas-params "gsl_monte_vegas_params"
(alpha "alpha" :type :double)
(iterations "iterations" :type :sizet)
(stage "stage" :type :int)
(mode "mode" :type monte-carlo-vegas-mode)
(verbose "verbose" :type :int)
(output-stream "ostream" :type :pointer))
;; Monte Carlo Integration
;; Liam Healy Sat Feb 3 2007 - 17:42
;; Time-stamp: <2011-01-10 17:59:20EST monte-carlo.lisp>
;; Time-stamp: <2016-06-14 23:07:35EDT monte-carlo.lisp>
;;
;; Copyright 2007, 2008, 2009, 2011 Liam M. Healy
;; Copyright 2007, 2008, 2009, 2011, 2012, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -31,7 +31,7 @@
(defmobject monte-carlo-plain
"gsl_monte_plain"
((dim sizet))
((dim :sizet))
"plain Monte Carlo integration"
:documentation ; FDL
"Make and initialize a workspace for Monte Carlo integration in dimension dim."
......@@ -52,13 +52,13 @@
"gsl_monte_plain_integrate"
((callback :pointer)
((grid:foreign-pointer lower-limits) :pointer) ((grid:foreign-pointer upper-limits) :pointer)
((dim0 lower-limits) sizet) (number-of-samples sizet)
((dim0 lower-limits) :sizet) (number-of-samples :sizet)
((mpointer generator) :pointer)
((mpointer state) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:inputs (lower-limits upper-limits)
:callbacks
(callback fnstruct-dimension (dimension)
(callback (:struct fnstruct-dimension) (dimension)
(function :double (:input :double :cvector dim0) :slug))
:callback-dynamic (((dim0 lower-limits)) (function scalars))
:documentation ; FDL
......@@ -83,7 +83,7 @@
(defmobject monte-carlo-miser
"gsl_monte_miser"
((dim sizet))
((dim :sizet))
"miser Monte Carlo integration"
:documentation ; FDL
"Make and initialize a workspace for Monte Carlo integration in
......@@ -92,7 +92,38 @@
:initialize-suffix "init"
:initialize-args nil)
(export 'miser-parameter)
(defmfun get-mcm-parameters (object)
"gsl_monte_miser_params_get"
(((mpointer object) :pointer) (params (:pointer (:struct miser-params))))
:c-return :void
:return (params)
:documentation "Get all parameters, as a foreign struct, for the MISER method."
:export nil
:index parameter
:gsl-version (1 13))
(defmethod parameter ((object monte-carlo-miser) parameter)
(cffi:foreign-slot-value (get-mcm-parameters object) 'miser-params parameter))
(defmfun set-mcm-parameters (object params)
"gsl_monte_miser_params_set"
(((mpointer object) :pointer) (params (:pointer (:struct miser-params))))
:documentation "Set the parameter for the MISER method."
:c-return :void
:return (params)
:export nil
:index (setf parameter)
:gsl-version (1 13))
(defmethod (setf parameter) (value (object monte-carlo-miser) parameter)
(let ((current-params (get-mcm-parameters object)))
(setf (cffi:foreign-slot-value current-params '(:struct miser-params) parameter)
value)
(set-mcm-parameters object current-params)))
;;; As of GSL v1.13, the API above is used to get/set the MISER parameters, so the following is removed.
#+obsolete-gsl (export 'miser-parameter)
#+obsolete-gsl
(defmacro miser-parameter (workspace parameter)
;; FDL
"Get or set with setf the parameter value for the MISER Monte Carlo
......@@ -113,13 +144,13 @@
"gsl_monte_miser_integrate"
((callback :pointer)
((grid:foreign-pointer lower-limits) :pointer) ((grid:foreign-pointer upper-limits) :pointer)
((dim0 lower-limits) sizet) (number-of-samples sizet)
((dim0 lower-limits) :sizet) (number-of-samples :sizet)
((mpointer generator) :pointer)
((mpointer state) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:inputs (lower-limits upper-limits)
:callbacks
(callback fnstruct-dimension (dimension)
(callback (:struct fnstruct-dimension) (dimension)
(function :double (:input :double :cvector dim0) :slug))
:callback-dynamic (((dim0 lower-limits)) (function scalars))
:documentation ; FDL
......@@ -144,7 +175,7 @@
(defmobject monte-carlo-vegas
"gsl_monte_vegas"
((dim sizet))
((dim :sizet))
"vegas Monte Carlo integration"
:documentation ; FDL
"Make and initialize a workspace for Monte Carlo integration in
......@@ -153,7 +184,38 @@
:initialize-suffix "init"
:initialize-args nil)
(defmfun get-mcv-parameters (object)
"gsl_monte_vegas_params_get"
(((mpointer object) :pointer) (params (:pointer (:struct vegas-params))))
:c-return :void
:return (params)
:documentation "Get all parameters, as a foreign struct, for the VEGAS method."
:export nil
:index parameter
:gsl-version (1 13))
(defmethod parameter ((object monte-carlo-vegas) parameter)
(cffi:foreign-slot-value (get-mcv-parameters object) 'vegas-params parameter))
(defmfun set-mcv-parameters (object params)
"gsl_monte_vegas_params_set"
(((mpointer object) :pointer) (params (:pointer (:struct vegas-params))))
:c-return :void
:return (params)
:export nil
:index (setf parameter)
:gsl-version (1 13))
(defmethod (setf parameter) (value (object monte-carlo-vegas) parameter)
(let ((current-params (get-mcv-parameters object)))
(setf (cffi:foreign-slot-value current-params '(:struct vegas-params) parameter)
value)
(set-mcv-parameters object current-params)))
;;; As of GSL v1.13, the API above is used to get/set the VEGAS parameters, so the following is removed.
#+obsolete-gsl
(export 'vegas-parameter)
#+obsolete-gsl
(defmacro vegas-parameter (workspace parameter)
;; FDL
"Get or set with setf the parameter value for the VEGAS Monte Carlo
......@@ -174,13 +236,13 @@
"gsl_monte_vegas_integrate"
((callback :pointer)
((grid:foreign-pointer lower-limits) :pointer) ((grid:foreign-pointer upper-limits) :pointer)
((dim0 lower-limits) sizet) (number-of-samples sizet)
((dim0 lower-limits) :sizet) (number-of-samples :sizet)
((mpointer generator) :pointer)
((mpointer state) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:inputs (lower-limits upper-limits)
:callbacks
(callback fnstruct-dimension (dimension)
(callback (:struct fnstruct-dimension) (dimension)
(function :double (:input :double :cvector dim0) :slug))
:callback-dynamic (((dim0 lower-limits)) (function scalars))
:documentation ; FDL
......@@ -208,7 +270,9 @@
(* (/ (expt dpi 3))
(/ (- 1 (* (cos x) (cos y) (cos z))))))
(defparameter *mc-lower* #m(0.0d0 0.0d0 0.0d0))
(defparameter *mc-lower*
(grid:make-foreign-array
'double-float :initial-contents '(0.0d0 0.0d0 0.0d0)))
(defparameter *mc-upper*
(grid:make-foreign-array
......
;; Numerical differentiation.
;; Liam Healy Mon Nov 12 2007 - 22:07
;; Time-stamp: <2009-12-27 09:42:10EST numerical-differentiation.lisp>
;; Time-stamp: <2011-10-30 10:27:07EDT numerical-differentiation.lisp>
;;
;; Copyright 2007, 2008, 2009 Liam M. Healy
;; Copyright 2007, 2008, 2009, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -27,7 +27,7 @@
((callback :pointer) (x :double) (step :double)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the numerical derivative of the function
......@@ -50,7 +50,7 @@
((callback :pointer) (x :double) (step :double)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the numerical derivative of the function
......@@ -75,7 +75,7 @@
((callback :pointer) (x :double) (step :double)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the numerical derivative of the function at the point x
......
;; Numerical integration techniques that require tables
;; Liam Healy 2009-04-04 15:24:05EDT
;; Time-stamp: <2010-08-07 21:41:16EDT numerical-integration-with-tables.lisp>
;; Time-stamp: <2012-01-13 12:01:39EST numerical-integration-with-tables.lisp>
;;
;; Copyright 2009 Liam M. Healy
;; Copyright 2009, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -62,10 +62,10 @@
(a :double) (b :double)
((mpointer table) :pointer)
(absolute-error :double) (relative-error :double)
(limit sizet) ((mpointer workspace) :pointer)
(limit :sizet) ((mpointer workspace) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the integral of the function f(x) over the interval (a,b)
......@@ -86,7 +86,7 @@
(defmobject qawo-table
"gsl_integration_qawo_table"
((omega :double) (L :double) (trig integrate-sine-cosine) (n sizet))
((omega :double) (L :double) (trig integrate-sine-cosine) (n :sizet))
"table for QAWO numerical integration method"
:documentation ; FDL
"Make a table describing a sine or cosine weight function W(x) with
......@@ -119,11 +119,11 @@
((callback :pointer)
(a :double)
(absolute-error :double) (relative-error :double)
(limit sizet) ((mpointer workspace) :pointer)
(limit :sizet) ((mpointer workspace) :pointer)
((mpointer table) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Use an adaptive algorithm to compute the integral of f over (a,b)
......@@ -162,12 +162,12 @@
((callback :pointer)
(a :double)
(absolute-error :double)
(limit sizet)
(limit :sizet)
((mpointer workspace) :pointer) ((mpointer cycle-workspace) :pointer)
((mpointer table) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"This function attempts to compute a Fourier integral of the
......
;; Numerical integration
;; Liam Healy, Wed Jul 5 2006 - 23:14
;; Time-stamp: <2011-01-10 17:59:21EST numerical-integration.lisp>
;; Time-stamp: <2015-01-22 23:32:29EST numerical-integration.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011 Liam M. Healy
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -50,9 +50,9 @@
(a :double) (b :double)
(absolute-error :double) (relative-error :double)
(result (:pointer :double)) (abserr (:pointer :double))
(neval (:pointer sizet)))
(neval (:pointer :sizet)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Apply the Gauss-Kronrod 10-point, 21-point, 43-point and
......@@ -70,7 +70,7 @@
;;;;****************************************************************************
(defmobject integration-workspace
"gsl_integration_workspace" ((size sizet))
"gsl_integration_workspace" ((size :sizet))
"integration workspace"
:documentation ; FDL
"Make a workspace sufficient to hold n double
......@@ -89,10 +89,10 @@
((callback :pointer)
(a :double) (b :double)
(absolute-error :double) (relative-error :double)
(limit sizet) (method integrate-method) ((mpointer workspace) :pointer)
(limit :sizet) (method integrate-method) ((mpointer workspace) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Apply an integration rule adaptively until an estimate
......@@ -125,11 +125,11 @@
"gsl_integration_qags"
((callback :pointer)
(a :double) (b :double)
(absolute-error :double) (relative-error :double) (limit sizet)
(absolute-error :double) (relative-error :double) (limit :sizet)
((mpointer workspace) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Apply the Gauss-Kronrod 21-point integration rule
......@@ -157,13 +157,13 @@
(limit 1000) (workspace (make-integration-workspace limit)))
"gsl_integration_qagp"
((callback :pointer)
((grid:foreign-pointer points) :pointer) ((dim0 points) sizet)
(absolute-error :double) (relative-error :double) (limit sizet)
((grid:foreign-pointer points) :pointer) ((dim0 points) :sizet)
(absolute-error :double) (relative-error :double) (limit :sizet)
((mpointer workspace) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:inputs (points)
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Apply the adaptive integration algorithm QAGS taking
......@@ -189,11 +189,11 @@
(limit 1000) (workspace (make-integration-workspace limit)))
"gsl_integration_qagi"
((callback :pointer)
(absolute-error :double) (relative-error :double) (limit sizet)
(absolute-error :double) (relative-error :double) (limit :sizet)
((mpointer workspace) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the integral of the function f over the
......@@ -214,11 +214,11 @@
(limit 1000) (workspace (make-integration-workspace limit)))
"gsl_integration_qagiu"
((callback :pointer) (a :double)
(absolute-error :double) (relative-error :double) (limit sizet)
(absolute-error :double) (relative-error :double) (limit :sizet)
((mpointer workspace) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the integral of the function f over the
......@@ -235,11 +235,11 @@
(limit 1000) (workspace (make-integration-workspace limit)))
"gsl_integration_qagil"
((callback :pointer) (b :double)
(absolute-error :double) (relative-error :double) (limit sizet)
(absolute-error :double) (relative-error :double) (limit :sizet)
((mpointer workspace) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the integral of the function f over the
......@@ -261,11 +261,11 @@
"gsl_integration_qawc"
((callback :pointer)
(a :double) (b :double) (c :double)
(absolute-error :double) (relative-error :double) (limit sizet)
(absolute-error :double) (relative-error :double) (limit :sizet)
((mpointer workspace) :pointer)
(result (:pointer :double)) (abserr (:pointer :double)))
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:callback-dynamic (nil (function))
:documentation ; FDL
"Compute the Cauchy principal value of the integral of
......@@ -369,4 +369,9 @@
'integration-test-f454
(grid:copy-to (vector 0.0d0 1.0d0 (sqrt 2.0d0) 3.0d0))
0.0d0 1.0d-3 1000)
(integration-QAWc 'integration-test-f459 -1.0d0 5.0d0 0.0d0 0.0d0 1.0d-3 1000))
(integration-QAWc 'integration-test-f459 -1.0d0 5.0d0 0.0d0 0.0d0 1.0d-3 1000)
;; Check that integration-QAG is reentrant, but note this is not the
;; recommended way to do multivariate integration (see Monte Carlo).
(integration-QAG (lambda (x)
(integration-QAG (lambda (y) (* (sin x) y)) 0d0 1d0 :gauss41))
0d0 pi :gauss41))
;; Chebyshev Approximations
;; Liam Healy Sat Nov 17 2007 - 20:36
;; Time-stamp: <2010-06-29 21:47:34EDT chebyshev.lisp>
;; Time-stamp: <2012-01-13 12:01:09EST chebyshev.lisp>
;;
;; Copyright 2007, 2008, 2009, 2010 Liam M. Healy
;; Copyright 2007, 2008, 2009, 2010, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -27,12 +27,12 @@
;;;;****************************************************************************
(defmobject chebyshev "gsl_cheb"
((order sizet))
((order :sizet))
"Chebyshev series"
:documentation ; FDL
"Make a Chebyshev series of specified order."
:callbacks
(callback fnstruct nil (function :double (:input :double) :slug))
(callback (:struct fnstruct) nil (function :double (:input :double) :slug))
:initialize-suffix "init"
:initialize-args
((callback :pointer) (lower-limit :double) (upper-limit :double))
......@@ -43,7 +43,7 @@
(((mpointer object) :pointer))
:definition :method
:documentation "The order of Chebyshev series."
:c-return sizet
:c-return :sizet
:gsl-version (1 12))
(defmfun size ((chebyshev chebyshev))
......@@ -51,7 +51,7 @@
(((mpointer chebyshev) :pointer))
:definition :method
:documentation "The length of the Chebyshev coefficient array."
:c-return sizet
:c-return :sizet
:gsl-version (1 12))
(defmfun coefficients (chebyshev)
......@@ -75,7 +75,7 @@
(defmfun evaluate ((object chebyshev) x &key order)
("gsl_cheb_eval" "gsl_cheb_eval_n")
((((mpointer object) :pointer) (x :double))
(((mpointer object) :pointer) (order sizet) (x :double)))
(((mpointer object) :pointer) (order :sizet) (x :double)))
:definition :method
:callback-object object
:c-return :double
......@@ -87,7 +87,7 @@
("gsl_cheb_eval_err" "gsl_cheb_eval_n_err")
((((mpointer chebyshev) :pointer) (x :double)
(result (:pointer :double)) (abserr (:pointer :double)))
(((mpointer chebyshev) :pointer) (order sizet) (x :double)
(((mpointer chebyshev) :pointer) (order :sizet) (x :double)
(result (:pointer :double)) (abserr (:pointer :double))))
:documentation ; FDL
"Evaluate the Chebyshev series at a point x, returning result and
......
;; CFFI-Grovel definitions for unix systems.
;; Liam Healy 2009-06-06 09:36:29EDT array-structs.lisp
;; Time-stamp: <2010-07-18 22:52:48EDT array-structs.lisp>
;; Time-stamp: <2012-01-13 12:01:37EST array-structs.lisp>
;;
;; Copyright 2009, 2010 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -31,14 +31,14 @@
(include "gsl/gsl_block_double.h")
(cstruct gsl-block-c "gsl_block"
(size "size" :type sizet)
(size "size" :type :sizet)
(data "data" :type :pointer))
(include "gsl/gsl_vector_double.h")
(cstruct gsl-vector-c "gsl_vector"
(size "size" :type sizet)
(stride "stride" :type sizet)
(size "size" :type :sizet)
(stride "stride" :type :sizet)
(data "data" :type :pointer)
(block "block" :type :pointer)
(owner "owner" :type :int))
......@@ -46,9 +46,9 @@
(include "gsl/gsl_matrix_double.h")
(cstruct gsl-matrix-c "gsl_matrix"
(size0 "size1" :type sizet)
(size1 "size2" :type sizet)
(tda "tda" :type sizet)
(size0 "size1" :type :sizet)
(size1 "size2" :type :sizet)
(tda "tda" :type :sizet)
(data "data" :type :pointer)
(block "block" :type :pointer)
(owner "owner" :type :int))
......@@ -56,12 +56,12 @@
(include "gsl/gsl_permutation.h")
(cstruct gsl-permutation-c "gsl_permutation"
(size "size" :type sizet)
(size "size" :type :sizet)
(data "data" :type :pointer))
(include "gsl/gsl_combination.h")
(cstruct gsl-combination-c "gsl_combination"
(range "n" :type sizet)
(size "k" :type sizet)
(range "n" :type :sizet)
(size "k" :type :sizet)
(data "data" :type :pointer))
;; Functions for both vectors and matrices.
;; Liam Healy 2008-04-26 20:48:44EDT both.lisp
;; Time-stamp: <2011-01-12 00:38:30EST both.lisp>
;; Time-stamp: <2012-01-13 12:01:36EST both.lisp>
;;
;; Copyright 2008, 2009, 2010, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -27,9 +27,9 @@
(defmfun alloc-from-block ((object vector) blockptr)
("gsl_" :category :type "_alloc_from_block")
((blockptr :pointer)
(0 sizet) ; offset
((size object) sizet) ; number of elements
(1 sizet)) ; stride
(0 :sizet) ; offset
((size object) :sizet) ; number of elements
(1 :sizet)) ; stride
:definition :generic
:c-return :pointer
:export nil
......@@ -38,10 +38,10 @@
(defmfun alloc-from-block ((object grid:matrix) blockptr)
("gsl_" :category :type "_alloc_from_block")
((blockptr :pointer)
(0 sizet) ; offset
((first (grid:dimensions object)) sizet) ; number of rows
((second (grid:dimensions object)) sizet) ; number of columns
((second (grid:dimensions object)) sizet)) ; "tda" = number of columns for now
(0 :sizet) ; offset
((first (grid:dimensions object)) :sizet) ; number of rows
((second (grid:dimensions object)) :sizet) ; number of columns
((second (grid:dimensions object)) :sizet)) ; "tda" = number of columns for now
:definition :methods
:c-return :pointer
:export nil)
......@@ -81,7 +81,7 @@
;;;;****************************************************************************
;;;; Array elements; used in callbacks scalarsp=T only
;;;;****************************************************************************
;;; Normal foreign array access is with grid:gref, but in order to
;;; Normal foreign array access is with grid:aref, but in order to
;;; avoid the overhead of instantiating a foreign-array object to
;;; access components, we use these macros which expand to gsl_*_get
;;; and gsl_*_set.
......@@ -100,9 +100,9 @@
"Create a form to access the GSL array value from the mpointer. If value is not nil,
set the value; otherwise, get the value."
;; (access-value-int 'ptr 'grid:vector-unsigned-byte-16 45 '(3))
;; (FOREIGN-FUNCALL "gsl_vector_ushort_set" :POINTER PTR SIZET 3 :UNSIGNED-SHORT 45 :VOID)
;; (FOREIGN-FUNCALL "gsl_vector_ushort_set" :POINTER PTR :SIZET 3 :UNSIGNED-SHORT 45 :VOID)
;; (access-value-int 'ptr 'grid:matrix-unsigned-byte-16 nil '(45 3))
;; (FOREIGN-FUNCALL "gsl_matrix_ushort_get" :POINTER PTR SIZET 45 SIZET 3 :UNSIGNED-SHORT)
;; (FOREIGN-FUNCALL "gsl_matrix_ushort_get" :POINTER PTR :SIZET 45 :SIZET 3 :UNSIGNED-SHORT)
(let ((element-type (grid::farray-element-type class-name))
(matrixp (subtypep class-name 'grid:matrix)))
(unless (or (and matrixp (eql 2 (length indices)))
......@@ -116,8 +116,8 @@
(if matrixp 'grid:matrix 'vector)
element-type)
:pointer ,mpointer
sizet ,(first indices)
,@(when matrixp (list 'sizet (second indices)))
:sizet ,(first indices)
,@(when matrixp (list ':sizet (second indices)))
,(grid:cl-cffi element-type)
,@(when value `(,value :void)))))
......@@ -324,14 +324,14 @@
:definition :generic
:element-types :no-complex
:inputs (a)
:c-return sizet
:c-return :sizet
:documentation ; FDL
"The index of the minimum value in a. When there are several
equal minimum elements, then the lowest index is returned.")
(defmfun min-index ((a grid:matrix))
("gsl_" :category :type "_min_index")
(((mpointer a) :pointer) (imin (:pointer sizet)) (jmin (:pointer sizet)))
(((mpointer a) :pointer) (imin (:pointer :sizet)) (jmin (:pointer :sizet)))
:definition :methods
:element-types :no-complex
:inputs (a)
......@@ -343,14 +343,14 @@
:definition :generic
:element-types :no-complex
:inputs (a)
:c-return sizet
:c-return :sizet
:documentation ; FDL
"The index of the maximum value in a. When there are several
equal maximum elements, then the lowest index is returned.")
(defmfun max-index ((a grid:matrix))
("gsl_" :category :type "_max_index")
(((mpointer a) :pointer) (imin (:pointer sizet)) (jmin (:pointer sizet)))
(((mpointer a) :pointer) (imin (:pointer :sizet)) (jmin (:pointer :sizet)))
:definition :methods
:element-types :no-complex
:inputs (a)
......@@ -358,7 +358,7 @@
(defmfun minmax-index ((a vector))
("gsl_" :category :type "_minmax_index")
(((mpointer a) :pointer) (imin (:pointer sizet)) (jmin (:pointer sizet)))
(((mpointer a) :pointer) (imin (:pointer :sizet)) (jmin (:pointer :sizet)))
:definition :generic
:element-types :no-complex
:inputs (a)
......@@ -372,8 +372,8 @@
(defmfun minmax-index ((a grid:matrix))
("gsl_" :category :type "_minmax_index")
(((mpointer a) :pointer)
(imin (:pointer sizet)) (jmin (:pointer sizet))
(imax (:pointer sizet)) (jmax (:pointer sizet)))
(imin (:pointer :sizet)) (jmin (:pointer :sizet))
(imax (:pointer :sizet)) (jmax (:pointer :sizet)))
:definition :methods
:element-types :no-complex
:inputs (a)
......
;; Combinations
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2011-01-10 18:16:28EST combination.lisp>
;; Time-stamp: <2016-06-14 23:37:59EDT combination.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011 Liam M. Healy
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -33,14 +33,14 @@
(defmethod initialize-instance :after
((object combination) &key range dimensions &allow-other-keys)
(let ((mptr (cffi:foreign-alloc 'gsl-combination-c)))
(let ((mptr (cffi:foreign-alloc '(:struct gsl-combination-c))))
(setf (grid:metadata-slot object 'mpointer)
mptr
(cffi:foreign-slot-value mptr 'gsl-combination-c 'data)
(cffi:foreign-slot-value mptr '(:struct gsl-combination-c) 'data)
(grid:foreign-pointer object)
(cffi:foreign-slot-value mptr 'gsl-combination-c 'range)
(cffi:foreign-slot-value mptr '(:struct gsl-combination-c) 'range)
range
(cffi:foreign-slot-value mptr 'gsl-combination-c 'size)
(cffi:foreign-slot-value mptr '(:struct gsl-combination-c) 'size)
(first dimensions))
(tg:finalize object (lambda () (cffi:foreign-free mptr)))))
......@@ -123,7 +123,7 @@
(defmfun combination-range (c)
"gsl_combination_n"
(((mpointer c) :pointer))
:c-return sizet
:c-return :sizet
:inputs (c)
:documentation ; FDL
"The range (n), or maximum possible value (n in the (n k) notation)
......@@ -133,7 +133,7 @@
"gsl_combination_k"
(((mpointer c) :pointer))
:definition :method
:c-return sizet
:c-return :sizet
:documentation ; FDL
"The number of elements (k) in the combination c.")
......
;; A grid:foreign-array with added metadata for GSL.
;; Liam Healy 2008-04-06 21:23:41EDT
;; Time-stamp: <2011-01-12 00:34:42EST foreign-array.lisp>
;; Time-stamp: <2016-06-14 23:30:39EDT foreign-array.lisp>
;;
;; Copyright 2008, 2009, 2010, 2011 Liam M. Healy
;; Copyright 2008, 2009, 2010, 2011, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -40,10 +40,10 @@
(unless (grid:metadata-slot object 'mpointer)
(when (zerop (size object))
(error "Object ~a has zero total dimension." object))
(let ((blockptr (cffi:foreign-alloc 'gsl-block-c)))
(setf (cffi:foreign-slot-value blockptr 'gsl-block-c 'size)
(let ((blockptr (cffi:foreign-alloc '(:struct gsl-block-c))))
(setf (cffi:foreign-slot-value blockptr '(:struct gsl-block-c) 'size)
(size object)
(cffi:foreign-slot-value blockptr 'gsl-block-c 'data)
(cffi:foreign-slot-value blockptr '(:struct gsl-block-c) 'data)
(grid:foreign-pointer object)
(grid:metadata-slot object 'block-pointer) blockptr)
(let ((array-struct (alloc-from-block object blockptr)))
......@@ -53,7 +53,10 @@
;; from the block to the vector/matrix; we must do that manually here
(cffi:foreign-slot-value
array-struct
(if (typep object 'grid:matrix) 'gsl-matrix-c 'gsl-vector-c) 'data)
(if (typep object 'grid:matrix)
'(:struct gsl-matrix-c)
'(:struct gsl-vector-c))
'data)
(grid:foreign-pointer object))
(tg:finalize object
(lambda ()
......@@ -77,8 +80,7 @@
(defun make-foreign-array-from-mpointer
(mpointer
&optional (element-type 'double-float) (category-or-rank 'vector) finalize)
"Make the foreign array when a GSL pointer to a
gsl-vector-c or gsl-matrix-c is given."
"Make the foreign array when a GSL pointer to a gsl-vector-c or gsl-matrix-c is given."
(let* ((category
(case category-or-rank
((vector :vector 1) 'vector)
......@@ -86,8 +88,8 @@
(t (error "Unrecognized category ~a" category-or-rank))))
(cstruct
(case category
(vector 'gsl-vector-c)
(grid:matrix 'gsl-matrix-c)))
(vector '(:struct gsl-vector-c))
(grid:matrix '(:struct gsl-matrix-c))))
(fa
(grid:make-grid
(case category
......
;; Matrices
;; Liam Healy 2008-04-15 21:57:52EDT matrix.lisp
;; Time-stamp: <2011-01-12 00:34:45EST matrix.lisp>
;; Time-stamp: <2012-01-13 12:01:35EST matrix.lisp>
;;
;; Copyright 2008, 2009, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -46,7 +46,7 @@
(defmfun row ((matrix grid:matrix) i
&optional (vector (grid:make-foreign-array element-type :dimensions (dim1 matrix))))
("gsl_matrix" :type "_get_row")
(((mpointer vector) :pointer) ((mpointer matrix) :pointer) (i sizet))
(((mpointer vector) :pointer) ((mpointer matrix) :pointer) (i :sizet))
:definition :generic
:inputs (matrix)
:outputs (vector)
......@@ -58,7 +58,7 @@
(defmfun (setf row) ((vector vector) (matrix grid:matrix) i)
("gsl_matrix" :type "_set_row")
(((mpointer matrix) :pointer) (i sizet) ((mpointer vector) :pointer))
(((mpointer matrix) :pointer) (i :sizet) ((mpointer vector) :pointer))
:definition :generic
:inputs (vector matrix)
:outputs (matrix)
......@@ -70,7 +70,7 @@
(defmfun column ((matrix grid:matrix) i
&optional (vector (grid:make-foreign-array element-type :dimensions (dim0 matrix))))
("gsl_matrix" :type "_get_col")
(((mpointer vector) :pointer) ((mpointer matrix) :pointer) (i sizet))
(((mpointer vector) :pointer) ((mpointer matrix) :pointer) (i :sizet))
:definition :generic
:inputs (matrix)
:outputs (vector)
......@@ -82,7 +82,7 @@
(defmfun (setf column) ((vector vector) (matrix grid:matrix) i)
("gsl_matrix" :type "_set_col")
(((mpointer matrix) :pointer) (i sizet) ((mpointer vector) :pointer))
(((mpointer matrix) :pointer) (i :sizet) ((mpointer vector) :pointer))
:definition :generic
:inputs (vector matrix)
:outputs (matrix)
......@@ -97,7 +97,7 @@
(defmfun swap-rows ((matrix grid:matrix) i j)
("gsl_matrix" :type "_swap_rows")
(((mpointer matrix) :pointer) (i sizet) (j sizet))
(((mpointer matrix) :pointer) (i :sizet) (j :sizet))
:definition :generic
:return (matrix)
:inputs (matrix)
......@@ -107,7 +107,7 @@
(defmfun swap-columns ((matrix grid:matrix) i j)
("gsl_matrix" :type "_swap_columns")
(((mpointer matrix) :pointer) (i sizet) (j sizet))
(((mpointer matrix) :pointer) (i :sizet) (j :sizet))
:definition :generic
:return (matrix)
:inputs (matrix)
......@@ -117,7 +117,7 @@
(defmfun swap-row-column ((matrix grid:matrix) i j)
("gsl_matrix" :type "_swap_rowcol")
(((mpointer matrix) :pointer) (i sizet) (j sizet))
(((mpointer matrix) :pointer) (i :sizet) (j :sizet))
:definition :generic
:return (matrix)
:inputs (matrix)
......
;; Permutations
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2011-01-10 18:16:26EST permutation.lisp>
;; Time-stamp: <2017-01-01 17:20:46EST permutation.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011 Liam M. Healy
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2016, 2017 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -27,57 +27,25 @@
;;;; Permutation structure and CL object
;;;;****************************************************************************
(defclass permutation
(#+int64 grid:vector-unsigned-byte-64 #+int32 grid:vector-unsigned-byte-32)
()
(:documentation "GSL permutations."))
(defmethod initialize-instance :after
((object permutation) &key dimensions &allow-other-keys)
(let ((mptr (cffi:foreign-alloc 'gsl-permutation-c)))
(setf (grid:metadata-slot object 'mpointer)
mptr
(cffi:foreign-slot-value mptr 'gsl-permutation-c 'data)
(grid:foreign-pointer object)
(cffi:foreign-slot-value mptr 'gsl-permutation-c 'size)
(first dimensions))
(tg:finalize object (lambda () (cffi:foreign-free mptr)))))
(export 'make-permutation)
(defun make-permutation (n &optional (initialize t))
"Make the object representing a permutation of n objects.
If n is a permutation, make a new permutation of the same size. If
initialize is T (default), set to the identity permutation if n is
an integer, or copy the permutation if it's a permutation."
(let ((perm
(make-instance
'permutation
:element-type '(unsigned-byte #+int64 64 #+int32 32)
:dimensions (if (typep n 'permutation) (grid:dimensions n) (list n)))))
(when initialize
(if (typep n 'permutation)
(error "not available yet") ; (copy perm n)
(set-identity perm)))
perm))
(defmobject permutation
"gsl_permutation"
((size :sizet))
"permutation"
:initialize-when-making :default-t
:ri-c-return :void
:initialize-suffix "init")
(defmethod print-object ((object permutation) stream)
(print-unreadable-object (object stream :type t)
(princ (grid:contents object) stream)))
(format stream "size ~d contents ~a" (size object) (grid:contents object))))
;;;;****************************************************************************
;;;; Setting values
;;;; Setting/getting values
;;;;****************************************************************************
(defmfun set-identity ((permutation permutation))
"gsl_permutation_init"
(((mpointer permutation) :pointer))
:definition :method
:c-return :void
:outputs (permutation)
:return (permutation)
:documentation ; FDL
"Initialize the permutation p to the identity, i.e.
(0,1,2,...,n-1).")
(defmethod set-identity ((p permutation))
"Initialize the permutation p to the identity, i.e. (0,1,2,...,n-1)."
(reinitialize-instance p))
(defmfun perm-copy (source destination)
"gsl_permutation_memcpy"
......@@ -101,7 +69,7 @@
(defmfun swap-elements ((p permutation) i j)
"gsl_permutation_swap"
(((mpointer p) :pointer) (i sizet) (j sizet))
(((mpointer p) :pointer) (i :sizet) (j :sizet))
:definition :method
:inputs (p)
:outputs (p)
......@@ -109,6 +77,12 @@
:documentation ; FDL
"Exchanges the ith and jth elements of the permutation p.")
(defmfun grid:aref ((p permutation) &rest indices)
"gsl_permutation_get"
(((mpointer p) :pointer) ((first indices) :sizet))
:definition :method
:c-return :sizet)
;;;;****************************************************************************
;;;; Permutation properties
;;;;****************************************************************************
......@@ -117,11 +91,14 @@
"gsl_permutation_size"
(((mpointer p) :pointer))
:definition :method
:c-return sizet
:c-return :sizet
:inputs (p)
:documentation ; FDL
"The size of the permutation p.")
(defmethod grid:dimensions ((p permutation))
(list (size p)))
(defmfun permutation-data (p)
"gsl_permutation_data"
(((mpointer p) :pointer))
......@@ -220,14 +197,13 @@
(defmfun permute
(p (data #.grid:+foreign-pointer-class+) &optional (size 1) (stride 1))
"gsl_permute"
(((mpointer p) :pointer) (data :pointer) (stride sizet) (size sizet))
(((mpointer p) :pointer) (data :pointer) (stride :sizet) (size :sizet))
:definition :method
:inputs (p data)
:outputs (data)
:return (data)
:documentation ; FDL
"Apply the permutation p to the array data of
size n with stride stride.")
"Apply the permutation p to the array data of size n with stride stride.")
(defmfun permute-inverse
((p permutation) (v vector) &optional size stride)
......@@ -238,17 +214,12 @@
:outputs (v)
:return (v)
:documentation ; FDL
"Apply the permutation p to the elements of the
vector v considered as a row-vector acted on by a permutation
matrix from the right, v' = v P. The jth column of the
permutation matrix P is given by the p_j-th column of the
identity matrix. The permutation p and the vector v must
have the same length.")
"Apply the permutation p to the elements of the vector v considered as a row-vector acted on by a permutation matrix from the right, v' = v P. The jth column of the permutation matrix P is given by the p_j-th column of the identity matrix. The permutation p and the vector v must have the same length.")
(defmfun permute-inverse
(p (data #.grid:+foreign-pointer-class+) &optional (size 1) (stride 1))
"gsl_permute_inverse"
(((mpointer p) :pointer) (data :pointer) (stride sizet) (stride sizet))
(((mpointer p) :pointer) (data :pointer) (stride :sizet) (stride :sizet))
:definition :method
:inputs (p data)
:outputs (data)
......@@ -266,9 +237,7 @@
:outputs (p)
:return (p)
:documentation ; FDL
"Combine the two permutations pa and pb into a
single permutation p where p = pa . pb. The permutation
p is equivalent to applying pb first and then pa.")
"Combine the two permutations pa and pb into a single permutation p where p = pa . pb. The permutation p is equivalent to applying pb first and then pa.")
;;;;****************************************************************************
;;;; Permutations in cyclic form
......@@ -294,7 +263,7 @@
(defmfun inversions (p)
"gsl_permutation_inversions" (((mpointer p) :pointer))
:c-return sizet
:c-return :sizet
:inputs (p)
:documentation ; FDL
"Count the number of inversions in the permutation
......@@ -305,7 +274,7 @@
(defmfun linear-cycles (p)
"gsl_permutation_linear_cycles" (((mpointer p) :pointer))
:c-return sizet
:c-return :sizet
:inputs (p)
:documentation ; FDL
"Count the number of cycles in the permutation p, given in linear form.")
......@@ -313,7 +282,7 @@
(defmfun canonical-cycles (p)
"gsl_permutation_canonical_cycles"
(((mpointer p) :pointer))
:c-return sizet
:c-return :sizet
:inputs (p)
:documentation ; FDL
"Count the number of cycles in the permutation q, given in canonical form.")
......@@ -339,7 +308,7 @@
(save-test permutation
(let ((perm-1 (make-permutation 4 t)))
(grid:gref perm-1 2))
(grid:aref perm-1 2))
(let ((perm-1 (make-permutation 4 t))) ;grid:contents
(grid:contents perm-1))
(let ((perm-1 (make-permutation 4 t))) ;permutation-reverse
......@@ -357,7 +326,7 @@
(swap-elements perm-1 1 3)
(grid:contents perm-1))
(let ((perm-1 (make-permutation 4 t)) ;permute-vector
(intvec #31m(11 22 33 44)))
(intvec (grid:make-foreign-array '(signed-byte 32) :initial-contents '(11 22 33 44))))
(set-identity perm-1)
(swap-elements perm-1 1 3)
(swap-elements perm-1 0 2)
......
;; Vectors
;; Liam Healy 2008-04-13 09:39:02EDT vector.lisp
;; Time-stamp: <2010-06-28 11:03:32EDT vector.lisp>
;; Time-stamp: <2012-01-13 12:01:37EST vector.lisp>
;;
;; Copyright 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -28,7 +28,7 @@
(defmfun set-basis ((object vector) index)
("gsl_" :category :type "_set_basis")
(((mpointer object) :pointer) (index sizet))
(((mpointer object) :pointer) (index :sizet))
:definition :generic
:inputs (object)
:outputs (object)
......@@ -39,7 +39,7 @@
(defmfun swap-elements ((vec vector) i j)
("gsl_" :category :type "_swap_elements")
(((mpointer vec) :pointer) (i sizet) (j sizet))
(((mpointer vec) :pointer) (i :sizet) (j :sizet))
:definition :generic
:inputs (vec)
:outputs (vec)
......
......@@ -9,6 +9,21 @@
content="text/html; charset=iso-8859-1">
<link rev="made" href="mailto:lhealy@common-lisp.net">
<link rel="stylesheet" type="text/css" href="site.css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25052371-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="banner">
......@@ -93,50 +108,6 @@ function <code>examples</code>. There is also a suite of over
4000 tests; many of the examples also serve as tests, and most others
are ported from GSL's tests.
<h2>Requirements</h2>
<a name="require"/>
<p>
GSLL should work in any Common Lisp implementation and platform
combination for which the following are supported:</p>
<ul>
<li><a href="http://www.gnu.org/software/gsl/">GSL</a>
</li>
<li><a href="http://common-lisp.net/project/cffi/">CFFI</a> and cffi-grovel,
version 0.10.5 or newer; callbacks and <code>foreign-funcall</code>
must be supported.
</li>
<li><a href="http://www.cliki.net/trivial-garbage">trivial-garbage</a>
<li><a href="http://repo.or.cz/w/gsd.git">GSD</a>, the <i>Grid Structured Data</i>; in particular,
the <code>foreign-array</code> and <code>grid</code> systems, which
uses
<ul>
<li><a href="http://common-lisp.net/project/alexandria/">Alexandria</a>,</li>
<li><a href="http://www.cliki.net/SPLIT-SEQUENCE">split-sequence</a>,</li>
<li><a href="http://gitorious.org/iolib/static-vectors">static-vectors</a>
<i>(Optional)</i>, provides direct access to foreign arrays from
Lisp on some implementations.</li>
</ul>
<li><a href="http://www.cliki.net/asdf">ASDF</a></li>
<li><a href="http://repo.or.cz/w/lisp-unit.git">lisp-unit</a>, <i>(Optional)</i> necessary
to run <code>gsll-tests</code>
</li>
<li><a href="http://repo.or.cz/w/fsbv.git">FSBV</a>, <i>(Optional)</i> necessary
for functions using complex scalars or simulated annealing
</li>
<li>
<a href="http://common-lisp.net/project/iterate/">iterate</a>
and
<a href="http://common-lisp.net/project/asdf-system-connections/">asdf-system-connnections</a>,
<i>(Optional)</i>
provides a convenient way to iterate over elements or indices of
vectors or matrices.
</ul>
<p>Most users will not need to worry about their implementation and
operating system, as all these are supported if the needed libraries
are installed (see below). The use of CLISP, however, is not
recommended.
</p>
<h2>Download and Install</h2>
<h3>Download</h3>
<p>Use <a href="http://www.quicklisp.org/">quicklisp</a> and follow the
......@@ -147,24 +118,20 @@ combination for which the following are supported:</p>
and <code>libffi-dev</code>. Once they are installed and you have
loaded the quicklisp file:
<pre>
(ql:quickload "gsll-tests")</pre>
(ql:quickload "gsll")</pre>
<p>To test your installation:
<pre>
(in-package :gsl)
(lisp-unit:run-tests)</pre>
(asdf:test-system :gsll)</pre>
<p>The result should look something like:
<pre>
ABSOLUTE-DEVIATION: 1 assertions passed, 0 failed.
ABSOLUTE-SUM: 4 assertions passed, 0 failed.
AIRY: 73 assertions passed, 0 failed.</pre>
<p>... (many lines deleted) ...
<pre>
VECTOR-VARIANCE-WITH-MEAN: 10 assertions passed, 0 failed.
WEIBULL: 60 assertions passed, 0 failed.
ZETA: 6 assertions passed, 0 failed.
TOTAL: 4019 assertions passed, 1 failed, 0 execution errors.</pre>
<p>You may see more failures.
Unit Test Summary
| 3997 assertions total
| 3992 passed
| 5 failed
| 6 execution errors
| 0 missing tests
</pre>
<p>You may see more failures; if you are not on a 64 bit platform you will see fewer assertions.
<h3>License</h3>
<p>
This software is distributed under
......@@ -226,11 +193,13 @@ T
<p>
GSLL has many functions that work on vectors (one-dimensional arrays)
and matrices (two-dimensional arrays). Foreign arrays are defined and
manipulated using the GSD collection which defines generic operations
on array-like objects; see the GSD documentation for more information.
GSLL supports all array element types that are supported by CFFI, the
CL implementation, GSL, and the platform. This list is available in
the variable <code>grid:*array-element-types*</code>.
manipulated using
the <a href="http://www.common-lisp.net/project/antik/">Antik</a>
which defines generic operations on array-like objects; see the Antik
documentation for more information. GSLL supports all array element
types that are supported by CFFI, the CL implementation, GSL, and the
platform. This list is available in the
variable <code>grid:*array-element-types*</code>.
<p>
<h3>Passing functions</h3>
......@@ -318,16 +287,9 @@ and arrays used internally or for function return.
<h2>Contact</h2>
<a name="contact"/>
<p>There is a <a
href="http://common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel">mailing
list</a> for all aspects of this project, including bug reports. In
addition, I am frequently on #lisp IRC channel as LiamH.
</p>
<p>For bug reports, please use the mailing list. If you have
patch(es) and use git, please commit your changes and do:
<p>There is a <a href="https://mailman.common-lisp.net/listinfo/gsll-devel">mailing list</a> for all aspects of this project, including bug reports. See also the <a href="https://mailman.common-lisp.net/pipermail/gsll-devel/">archives</a>. In addition, I am frequently on #lisp IRC channel as LiamH. For bug reports, please use the mailing list. The <a href="https://gitlab.common-lisp.net/antik/gsll">development site</a> for GSLL has the git repository. If you have patch(es), please commit your changes and do:
<pre>git format-patch origin</pre>
<p>This will produce one or more files whose names start with a
four-digit number; please attach them all to your email.
<p>This will produce one or more files whose names start with a four-digit number; please attach them all to your email.
</div>
<!-- Page published by Emacs Muse ends here -->
<div class="footer">
......@@ -336,18 +298,9 @@ four-digit number; please attach them all to your email.
<!-- Created: Feb 25 2005 -->
<!-- hhmts start -->
<small>
Time-stamp: <2010-10-12 17:46:29EDT index.html>
Time-stamp: <2015-12-05 22:02:12EST index.html>
</small>
<!-- hhmts end -->
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3669275-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>
;; CFFI-Grovel definitions.
;; Liam Healy
;; Time-stamp: <2010-05-23 11:36:31EDT eigen-struct.lisp>
;; Time-stamp: <2012-01-13 12:01:34EST eigen-struct.lisp>
;;
;; Copyright 2009, 2010 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -31,4 +31,4 @@
(include "gsl/gsl_eigen.h")
(cstruct gsl-nonsymm-ws "gsl_eigen_nonsymm_workspace"
(n-evals "n_evals" :type sizet)) ; number of eigenvalues found
(n-evals "n_evals" :type :sizet)) ; number of eigenvalues found
;; Real generalized eigensystems
;; Liam Healy 2009-02-16 12:55:04EST real-generalized.lisp
;; Time-stamp: <2011-01-12 00:08:22EST generalized.lisp>
;; Time-stamp: <2012-01-13 12:01:34EST generalized.lisp>
;;
;; Copyright 2009, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -21,7 +21,7 @@
(in-package :gsl)
(defmobject eigen-gensymm
"gsl_eigen_gensymm" ((n sizet))
"gsl_eigen_gensymm" ((n :sizet))
"symmetric generalized eigenvalue workspace"
:gsl-version (1 10)
:documentation ; FDL
......@@ -30,7 +30,7 @@
is O(2n).")
(defmobject eigen-gensymmv
"gsl_eigen_gensymmv" ((n sizet))
"gsl_eigen_gensymmv" ((n :sizet))
"symmetric generalized eigensystem workspace"
:gsl-version (1 10)
:documentation ; FDL
......@@ -39,7 +39,7 @@
of the workspace is O(4n).")
(defmobject eigen-genherm
"gsl_eigen_genherm" ((n sizet))
"gsl_eigen_genherm" ((n :sizet))
"hermitian generalized eigenvalue workspace"
:gsl-version (1 10)
:documentation ; FDL
......@@ -48,7 +48,7 @@
workspace is O(3n).")
(defmobject eigen-genhermv
"gsl_eigen_genhermv" ((n sizet))
"gsl_eigen_genhermv" ((n :sizet))
"hermitian generalized eigensystem workspace"
:gsl-version (1 10)
:documentation ; FDL
......
;; Generalized eigensystems for nonsymmetric real matrices
;; Liam Healy 2009-02-16 14:27:20EST nonsymmetric-generalized.lisp
;; Time-stamp: <2011-01-10 18:19:14EST nonsymmetric-generalized.lisp>
;; Time-stamp: <2012-01-13 12:01:33EST nonsymmetric-generalized.lisp>
;;
;; Copyright 2009, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -21,7 +21,7 @@
(in-package :gsl)
(defmobject eigen-gen
"gsl_eigen_gen" ((n sizet))
"gsl_eigen_gen" ((n :sizet))
"generalized nonsymmetric eigenvalue workspace"
:gsl-version (1 10)
:documentation ; FDL
......@@ -30,7 +30,7 @@
is O(n).")
(defmobject eigen-genv
"gsl_eigen_genv" ((n sizet))
"gsl_eigen_genv" ((n :sizet))
"generalized nonsymmetric eigenvector and eigenvalue workspace"
:gsl-version (1 10)
:documentation ; FDL
......