sparsersb-1.0.9/COPYING0000644000000000000000000010451314122214045012705 0ustar 00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. 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. Copyright (C) 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 . 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: Copyright (C) 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 . 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 . sparsersb-1.0.9/DESCRIPTION0000644000000000000000000000104714122214045013356 0ustar 00000000000000Name: sparsersb Version: 1.0.9 Date: 2021-09-21 Author: Michele Martone Maintainer: Michele Martone Title: Interface to the librsb package implementing the RSB sparse matrix format. Description: Interface to the librsb package implementing the RSB sparse matrix format for fast shared-memory sparse matrix computations. Depends: octave (>= 4.4.0) License: GPLv3+ Url: http://librsb.sourceforge.net/ Categories: Sparse Matrix Computations BuildRequires: librsb (>= 1.2.0.9) sparsersb-1.0.9/INDEX0000644000000000000000000000015414122214045012440 0ustar 00000000000000sparsersb >> Interface to the librsb package implementing the RSB sparse matrix format. Support sparsersb sparsersb-1.0.9/Makefile0000644000000000000000000000701014122214045013304 0ustar 00000000000000## Copyright 2017 Julien Bect ## Copyright 2015-2016 Carnë Draug ## Copyright 2015-2016 Oliver Heimlich ## ## Copying and distribution of this file, with or without modification, ## are permitted in any medium without royalty provided the copyright ## notice and this notice are preserved. This file is offered as-is, ## without any warranty. PACKAGE := $(shell grep "^Name: " DESCRIPTION | cut -f2 -d" ") VERSION := $(shell grep "^Version: " DESCRIPTION | cut -f2 -d" ") TARGET_DIR := $(CURDIR)/target RELEASE_DIR := $(TARGET_DIR)/$(PACKAGE)-$(VERSION) RELEASE_TARBALL := $(TARGET_DIR)/$(PACKAGE)-$(VERSION).tar.gz HTML_DIR := $(TARGET_DIR)/$(PACKAGE)-html HTML_TARBALL := $(TARGET_DIR)/$(PACKAGE)-html.tar.gz HG_ID := $(shell hg id --id | sed -e 's/+//') HG_DATE := $(shell hg log --rev $(HG_ID) --template {date\|isodate}) # Follows the recommendations of https://reproducible-builds.org/docs/archives # Note #1: GNU tar is assumed # Note #2: --format=ustar selects the 'ustar' (POSIX.1-1988) tar format define create_tarball $(shell cd $(dir $(1)) \ && find $(notdir $(1)) -print0 \ | LC_ALL=C sort -z \ | tar c --format=ustar --mtime="$(HG_DATE)" --mode=a+rX,u+w,go-w,ug-s \ --owner=0 --group=0 --numeric-owner \ --no-recursion --null -T - -f - \ | gzip -9n > "$(2)") endef M_SOURCES := $(wildcard inst/*.m) $(patsubst %.in,%,$(wildcard src/*.m.in)) OCTAVE ?= octave --no-window-system --silent .PHONY: all help dist html release install build-inplace check run clean # Default target release: dist html @echo " " @echo "Upload @ https://sourceforge.net/p/octave/package-releases/new/" @echo "and provide the following md5sums:" @cd $(TARGET_DIR) && md5sum \ $(notdir $(RELEASE_TARBALL)) \ $(notdir $(HTML_TARBALL)) @echo 'Execute: hg tag "release-${VERSION}" when the release is ready.' @echo " " help: @echo "Targets:" @echo " dist - Create $(RELEASE_TARBALL) for release" @echo " html - Create $(HTML_TARBALL) for release" @echo " release - Create both of the above and show md5sums" @echo @echo " install - Install the package in GNU Octave" @echo " check - Execute package tests (w/o install)" @echo " run - Run Octave with development in PATH (no install)" @echo @echo " clean - Remove releases, html documentation" %.tar.gz: % $(call create_tarball,$*,$@) $(RELEASE_DIR): .hg/dirstate @echo "Creating package version $(VERSION) release ..." -$(RM) -r "$@" hg archive --exclude ".hg*" --exclude "Makefile" --type files "$@" cd "$@/src" && ./autogen.sh && $(RM) -r "autom4te.cache" $(HTML_DIR): install @echo "Generating HTML documentation. This may take a while ..." -$(RM) -r "$@" cd src && $(OCTAVE) \ --eval "pkg load generate_html; " \ --eval 'generate_package_html ("${PACKAGE}", "$@", "octave-forge");' dist: $(RELEASE_TARBALL) html: $(HTML_TARBALL) install: $(RELEASE_TARBALL) @echo "Installing package locally ..." $(OCTAVE) --eval 'pkg ("install", "${RELEASE_TARBALL}")' build-inplace: src/sparsersb.oct src/configure: src/autogen.sh src/configure.ac cd src && ./autogen.sh src/Makeconf: src/configure src/Makeconf.in cd src && ./configure src/sparsersb.oct: src/Makefile src/Makeconf cd src && $(MAKE) sparsersb.oct check: src/sparsersb.oct $(MAKE) -C src tests run: src/sparsersb.oct $(OCTAVE) --persist --path "inst/" --path "src/" clean: $(RM) -r $(TARGET_DIR) $(MAKE) -C src clean $(RM) -rf src/autom4te.cache $(RM) src/Makeconf src/config.log src/config.status src/configure sparsersb-1.0.9/NEWS0000644000000000000000000001216014122214045012345 0ustar 00000000000000Summary of important user-visible changes for releases of the sparsersb package =============================================================================== sparsersb-1.0.9 Release Date: 2021-09-21 =============================================================================== ** Intended to be used with librsb-1.2.0.9 or later. ** - documented differences with sparse in multiplying sparsersb by sparsersb ** - documented differences with sparse in summing sparsersb by sparsersb ** - documented "symmetric" and "hermitian" specifiers ** - documented "symmetric" and "hermitian" (i,j) access ** - documented "symmetric" and "hermitian" (:,:) access ** - fix: conversion from symmetric complex sparsersb won't give hermitian ** - fix: conversion from diagonal complex sparse shan't give hermitian ** - fix: compatibility with Octave-6 in sparsersbtg.m ** - fix: avoid test requiring >1 threads failing on OMP_NUM_THREADS=1 ** - fix: avoid possible segfault crash (heap-use-after-free) ** - better message when trying to invert matrix with zeroes on diagonal ** - stricter error propagation when in `make tests' ** - more error verbosity =============================================================================== sparsersb-1.0.8 Release Date: 2020-08-06 =============================================================================== ** Intended to be used with librsb-1.2.0.9 or later. ** - fixed '*' giving bad results between real sparsersb and complex scalar ** - fixed '+' giving bad sum between real sparsersb and complex sparsersb ** - improved documentation, demos and tests ** - fix: hermitian sparsersb matrices were being marked with 'U', not 'H' ** - fix: avoid duplicate vector re-zeroing (so, a bit faster) =============================================================================== sparsersb-1.0.7 Release Date: 2020-01-07 =============================================================================== ** - fixed '*' operator: 2*sparsersb(...) now returns a sparsersb, not sparse ** - fixed '*' operation when one operand is real sparsersb and other complex ** - avoids internal octave API deprecated in 4.4 ** - builds with 4.4 till pre-release 6.0 ** - `make tests' shall fail on sparsersb not matching octave's sparse ** - implemented elemental transposition by complex: sparsersb.^complex ** - expand symmetry when converting sparsersb double to sparse ** - expand hermitian when converting sparsersb complex to sparse ** - 1-D indexing read access is meant to be like in sparse ** - (:), (:,:), (i,:), (:,j) access support implemented (but not efficient) ** - internal bug fixes ** - more test cases (for 'test librsb') =============================================================================== sparsersb-1.0.6 Release Date: 2018-06-15 =============================================================================== ** Intended to be used with the latest librsb-1.2.0. ** - fix of typo breaking builds (bug # #50764) =============================================================================== sparsersb-1.0.5 Release Date: 2017-03-29 =============================================================================== ** Intended to be used with the latest librsb-1.2.0. ** - tests won't use quit(): might emit exception according to bug #49271 =============================================================================== sparsersb-1.0.4 Release Date: 2017-03-25 =============================================================================== ** Intended to be used with the latest librsb-1.2.0. ** - test script now uses ilu() instead of obsolete luinc() =============================================================================== sparsersb-1.0.3 Release Date: 2017-03-24 =============================================================================== ** Intended to be used with the latest librsb-1.2.0. ** - "symmetric" RSB representation supported ** - improved documentation (including a few typos) ** - improved demos (demo sparsersb) ** - improved tests (test sparsersb) ** - improved error messages =============================================================================== sparsersb-1.0.2 Release Date: 2016-10-03 =============================================================================== ** Intended to be used with the latest librsb-1.2.0. ** - builds even if octave built with --enable-64, but limited to matrices ** which would fit when using a normal setup. =============================================================================== sparsersb-1.0.1 Release Date: 2016-08-01 =============================================================================== ** Intended to be used with the latest librsb-1.2.0. ** Changed sparsersb's `configure --help': ** - options to build librsb from a tarball (via configure or LIBRSB_TARBALL) ** - options to use librsb-config ** - options to override librsb-config ** - you can override the default C++11 flag =============================================================================== sparsersb-1.0.0 Release Date: 2015-05-31 =============================================================================== ** First Packaged Release. Intended to work with librsb-1.2. sparsersb-1.0.9/bin/demo_sparsersb.m0000755000000000000000000001330314122214045015607 0ustar 00000000000000# # Copyright (C) 2011-2017 Michele Martone # # 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 . # if length(getenv("SPARSERSB_TEST")) == 0 ; pkg load sparsersb ; end disp " ***********************************************************************" disp "** A usage example of sparsersb. **" disp "** A case large enough for 'sparsersb' to likely outperform 'sparse'. **" disp "** p.s.: Invoke 'demo sparsersb' to get just a first working overview. **" disp " ***********************************************************************" bs=100; # block size bo=10; # block overlap bc=700; # block count # bs=2; # block size # bo=1; # block overlap # bc=2; # block count nr=bs+(bc-1)*(bs-bo); nc=nr; disp "Constructing coefficients for a sparse diagonal blocks matrix." printf ("Will use %d blocks each wide %d and overlapping %d.\n", bc, bs, bo); ai=[]; aj=[]; av=[]; for i=1:bc # randomly generate block thr=0.3; b=rand(bs)+bc*eye(bs); b=b+b'; [bi,bj,bv]=find(b>thr); io=(i-1)*(bs-bo); # i offset jo=(i-1)*(bs-bo); # j offset ai=[ai;bi+io]; aj=[aj;bj+jo]; av=[av;bv ]; endfor nz=length(av); printf ("Obtained %.3e nonzeroes in a %d x %d matrix, average %.1e nonzeroes/row. \n", nz, nr, nc, nz/nr ); disp "Assembling a 'sparse' matrix..." tic; ao=sparse(ai,aj,av); printf ("Assembled 'sparse' in %.1es.\n", toc); disp "Assembling a 'sparsersb' matrix..." tic; ar=sparsersb(ai,aj,av); nsb=str2num(sparsersb(ar,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")); printf ("Assembled 'sparsersb' in %.1es (%d RSB blocks).\n", toc, nsb); # Uncomment to get more information: # printf ("RSB matrix specific info: %s.\n", ds=sparsersb(ar,"get")); # Uncomment the following to render the RSB blocks structure to a file. # sparsersb(ar,"render","demo_sparsersb_matrix.eps") maxt=4; nrhs=1; x=ones(nc,nrhs); y=ones(nr,nrhs); disp " ** Testing matrix-vector multiplication ********************************" disp "Benchmarking 'sparse' matrix-vector multiply..." nt=0;tic; while (toc < maxt) nt++;y+=ao*x; end ot=dt=toc;ot/=nt; printf ("Performed %8d 'sparse' matrix-vector multiplications in %.1es, %.2es each on average.\n", nt, dt, ot); disp "Benchmarking 'sparsersb' matrix-vector multiply..." nt=0;tic; while (toc < maxt) nt++;y+=ar*x; end rt=dt=toc;rt/=nt; printf ("Performed %8d 'sparsersb' matrix-vector multiplications in %.1es, %.2es each on average.\n", nt, dt, rt); printf ("So 'sparsersb' is %.2ex times as fast as 'sparse'.\n", ot/rt); disp "Attempting autotuning 'sparsersb' matrix..." tic; tr=sparsersb(ar,"autotune","n",nrhs); nnb=str2num(sparsersb(tr,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")); dt=toc; if ( nnb != nsb ) printf ("Performed autotuning in %.2es (%d -> %d RSB blocks).\n", dt, nsb, nnb); # Uncomment to get more information: # printf ("RSB matrix specific info: %s.\n", ds=sparsersb(tr,"get")); disp "Benchmarking 'sparsersb' matrix-matrix multiply..." nt=0;tic; while (toc < maxt) nt++;y+=ar*x; end rt=dt=toc;rt/=nt; printf ("Performed %8d 'sparsersb' matrix-vector multiplications in %.1es, %.2es each on average.\n", nt, dt, rt); printf ("So 'sparsersb' is %.2ex times as fast as 'sparse'.\n", ot/rt); else printf ("Autotuning procedure did not change the matrix.\n", dt, nsb, nnb); end disp " ** Testing matrix-matrix multiplication (rhs matrix is multi-vector) ***" nrhs=5; x=ones(nc,nrhs); y=ones(nr,nrhs); disp "Benchmarking 'sparse' matrix-matrix multiply..." nt=0;tic; while (toc < maxt) nt++;y+=ao*x; end ot=dt=toc;ot/=nt; printf ("Performed %8d 'sparse' matrix-matrix multiplications in %.1es, %.2es each on average.\n", nt, dt, ot); disp "Benchmarking 'sparsersb' matrix-matrix multiply..." nt=0;tic; while (toc < maxt) nt++;y+=ar*x; end rt=dt=toc;rt/=nt; printf ("Performed %8d 'sparsersb' matrix-matrix multiplications in %.1es, %.2es each on average.\n", nt, dt, rt); printf ("So 'sparsersb' is %.2ex times as fast as 'sparse'.\n", ot/rt); disp "Attempting autotuning 'sparsersb' matrix..." tic; tr=sparsersb(ar,"autotune","n",nrhs); nnb=str2num(sparsersb(tr,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")); dt=toc; if ( nnb != nsb ) printf ("Performed autotuning in %.2es (%d -> %d RSB blocks).\n", dt, nsb, nnb); # Uncomment to get more information: # printf ("RSB matrix specific info: %s.\n", ds=sparsersb(tr,"get")); disp "Benchmarking 'sparsersb' matrix-matrix multiply..." nt=0;tic; while (toc < maxt) nt++;y+=ar*x; end rt=dt=toc;rt/=nt; printf ("Performed %8d 'sparsersb' matrix-matrix multiplications in %.1es, %.2es each on average.\n", nt, dt, rt); printf ("So 'sparsersb' is %.2ex times as fast as 'sparse'.\n", ot/rt); else printf ("Autotuning procedure did not change the matrix.\n", dt, nsb, nnb); end disp " ***********************************************************************" disp "** You can adapt this benchmark to test your matrices so to check if **" disp "** they get multiplied faster with 'sparsersb' than with 'sparse'. **" disp " ***********************************************************************" sparsersb-1.0.9/bin/lsbench.m0000644000000000000000000000723114122214045014215 0ustar 00000000000000# # Copyright (C) 2011-2017 Michele Martone # # 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 . # # # Linear Solvers benchmark demos using sparsersb. # # TODO: this file shall host some linear system solution benchmarks using sparsersb. # It may serve as a reference point when profiling sparsersb/librsb. # Please note that sparsersb is optimized for large matrices. # 1; # This is a script disp " ***********************************************************************" disp "** Usage example of sparsersb solving linear systems with GMRES. **" disp "** Matrices large enough for 'sparsersb' to likely outperform 'sparse'.**" disp "** p.s.: Invoke 'demo sparsersb' to get just a first working overview. **" disp " ***********************************************************************" function lsb_compare(A) n=rows(A); maxit = n; b = ones (n, 1); P = diag (diag (A)); [i,j,v]=find(sparse(A)); minres=1e-7; disp " ***********************************************************************" printf("Solving a random system of %d equations, %d nonzeroes.\n",n,nnz(A)); disp " ***********************************************************************" tic; Ao = sparse (i,j,v,n,n);obt=toc; onz=nnz(Ao); tic; [X, FLAG, RELRES, ITER] = gmres (Ao, b, [], minres, maxit, P); odt=toc; cs="Octave "; onv=norm(Ao*X-b); oRELRES=RELRES; printf("%s took %.2e = %.2e + %.2e s and gave residual %g, flag %d, error norm %g.\n",cs,obt+odt,obt,odt,RELRES,FLAG,onv); tic; Ar = sparsersb (i,j,v,n,n);rbt=toc; #tic; Ar = sparsersb (Ao);rbt=toc; rnz=nnz(Ar); tic; [X, FLAG, RELRES, ITER] = gmres (Ar, b, [], minres, maxit, P); rdt=toc; cs="sparsersb"; rnv=norm(Ar*X-b); printf("%s took %.2e = %.2e + %.2e s and gave residual %g, flag %d, error norm %g.\n",cs,rbt+rdt,rbt,rdt,RELRES,FLAG,rnv); if (onz != rnz) printf("Error: seems like matrices don't match: %d vs %d nonzeroes!\n",onz,rnz); quit(1); else end if (RELRES>minres ) && (oRELRES %.1es) \n (matrix construction: %.1ex, %d iterations: %.1ex).\n",(obt+odt)/(rbt+rdt),(obt+odt),(rbt+rdt),(obt)/(rbt),iters,(odt)/(rdt)); #if (obt+odt)/(rbt+rdt) > 1.0 # printf("overall: %.1ex\n",(obt+odt)/(rbt+rdt)); #end end printf("\n"); end # This one is based on what Carlo De Falco once posted on the octave-dev mailing list: # (he used n=1000, k=15) # Toy size. #n = 4; #k = 1; #A= sqrt(k) * eye (n) + sprandn (n, n, .9); #lsb_compare(A); # Toy size. #n = 100; #k = 5; #A= sqrt(k) * eye (n) + sprandn (n, n, .8); #lsb_compare(A); n = 2000; k = 1000; A= sqrt(k) * eye (n) + sprandn (n, n, .4); lsb_compare(A); n = 5000; k = 1500; A= sqrt(k) * eye (n) + sprandn (n, n, .2); lsb_compare(A); disp "All done." disp "Notice how for large matrices the matrix construction is slower..." disp "... but multiplications are faster !" disp " ***********************************************************************" sparsersb-1.0.9/bin/obench.m0000644000000000000000000000663614122214045014045 0ustar 00000000000000# # Copyright (C) 2011-2017 Michele Martone # # 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 . # 1; # This is a script if length(getenv("SPARSERSB_TEST")) == 0 ; pkg load sparsersb ; end disp " ***********************************************************************" disp "** A small 'sparse' vs 'sparsersb' benchmark. **" disp "** On a few sample problems, tests: **" disp "** - matrix-vector multiplication (SPMV) **" disp "** - matrix-vector multiplication transposed (SPMV_T) **" disp "** - sparse matrix-spares matrix multiplication (SPGEMM) **" disp "** - and shows speedup ('RSB SPEEDUP' column) **" disp "** p.s.: Invoke 'demo sparsersb' to get just a first working overview. **" disp " ***********************************************************************" disp "OP ROWS COLUMNS NONZEROES OPTIME MFLOPS RSB SPEEDUP IMPLEMENTATION" cmt="#"; #for n_=1:6*0+1 for n_=1:6 for ro=0:1 n=n_*1000; m=k=n; # making vectors b=linspace(1,1,n)'; ox=linspace(1,1,n)'; bx=linspace(1,1,n)'; # making matrices r=(rand(n)>.6); om=sparse(r); nz=nnz(om); M=10^6; if ro==1 printf("%s%s\n",cmt," reordering with colamd..."); pct=-time; p=colamd(om); pct+=time; pat=-time; om=om(:,p); pat+=time; # TODO: use an array to select/specify the different reordering algorithms # printf("%g\t%g\t(%s)\n",(nz/M)/pct,(nz/M)/pat,"mflops for pct/pat"); printf("# ...colamd took %.1es (%.1e nnz/s), ",pct,nz/pct); printf( " permutation took %.1es (%.1e nnz/s)\n",pat,nz/pat); else printf("%s%s\n",cmt," testing with no reordering"); end #bm=sparsevbr(om); bm=sparsersb(sparse(om)); #bm=sparsersb3(sparse(om)); # stats flops=2*nz; ## spmv ot=-time; ox=om*b; ot+=time; # bt=-time; bx=bm*b; bt+=time; t=ot; p=["octave-",version]; mflops=(flops/M)/t; printf("%s\t%d\t%d\t%d\t%.1es\t%g\t%.1ex\t%s\n","SPMV ",m,k,nz,t,mflops,1 ,p); t=bt; p=["RSB"]; mflops=(flops/M)/t; printf("%s\t%d\t%d\t%d\t%.1es\t%g\t%.1ex\t%s\n","SPMV ",m,k,nz,t,mflops,ot/bt,p); ## spmvt ot=-time; ox=om.'*b; ot+=time; # bt=-time; bx=bm.'*b; bt+=time; t=ot; p=["octave-",version]; mflops=(flops/M)/t; printf("%s\t%d\t%d\t%d\t%.1es\t%g\t%.1ex\t%s\n","SPMV_T",m,k,nz,t,mflops,1 ,p); t=bt; p=["RSB"]; mflops=(flops/M)/t; printf("%s\t%d\t%d\t%d\t%.1es\t%g\t%.1ex\t%s\n","SPMV_T",m,k,nz,t,mflops,ot/bt,p); ## spgemm ot=-time; ox=om*om; ot+=time; # bt=-time; bx=bm*bm; bt+=time; t=ot; p=["octave-",version]; printf("%s\t%d\t%d\t%d\t%.1es\t\t%.1ex\t%s\n","SPGEMM",m,k,nz,t,1, p); t=bt; p=["RSB"]; printf("%s\t%d\t%d\t%d\t%.1es\t\t%.1ex\t%s\n","SPGEMM",m,k,nz,t,ot/bt,p); endfor endfor disp " ***********************************************************************" sparsersb-1.0.9/bin/octavebench.m0000755000000000000000000001362414122214045015066 0ustar 00000000000000#!/usr/bin/octave -q # # Copyright (C) 2011-2017 Michele Martone # # 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 . # 1; # This is a script # a benchmark program for octave/matlab # TODO: fix output format # TODO: correct symmetric / hermitian matrices handling # TODO: sound, time-and-runs-based benchmarking criteria if length(getenv("SPARSERSB_TEST")) == 0 ; pkg load sparsersb ; end disp " ***********************************************************************" disp "** A small 'sparse' vs 'sparsersb' test / benchmark. **" disp "** This is meant to be a demo, but not really an example. **" disp "** You can invoke it supplying a Matrix Market matrix (e.g. pd.mtx). **" disp "** Without arguments, will generate a test matrix. **" disp "** p.s.: Invoke 'demo sparsersb' to get just a first working overview. **" disp " ***********************************************************************" n=10; function printbenchline(matrixname,opname,sw,times,nnz,tottime,mxxops,bpnz,msstr) printf("FIXME (temporary format)\n"); printf("%s %s %s %d %d %.4f %10.2f %.4f %s\n",matrixname,opname,sw,times,nnz,tottime,mxxops,bpnz,msstr); end if nargin <= 0 # DGEMV benchmark disp "** Will generate a matrix... **" for o=1024:1024 #for o=1024:256:2048*2 m=rand(o); v=linspace(1,1,o)'; tic(); for i=1:n; m*v; end t=toc(); Mflops=n*2.0*nnz(m)/(10^6 * t); dgemvmflops=Mflops; printf("%d GEMV for order %d in %g secs, so %10f Mflops\n",n,o,t,n*2.0*o*o/(10^6 * t)); end disp " ***********************************************************************" else # nargin > 0 # if nargin > 0, we continue want_sparsersb_io=1; if want_sparsersb_io != 1 source("ext/mminfo.m"); source("ext/mmread.m"); source("ext/mmwrite.m"); end #matrices=ls("*.mtx")'; f=1; uc=2; # only 2 for the moment being. while f<=nargin MB=1024*1024; printf("** Will read Matrix Market matrix file %s ...\n",f); mmn=cell2mat(argv()(f))'; mn=strtrim(mmn'); tic(); #nm=mmread(mn); if want_sparsersb_io == 1 [nm,nrows,ncols,entries,rep,field,symm]=sparsersb(mn); nm=sparse(nm); if (symm=='S') uc+=1; end else [nm,nrows,ncols,entries,rep,field,symm]=mmread(mn); #if(symm=="symmetric")uc+=2;endif if(strcmp(symm,"symmetric"))uc+=1;endif end disp " " wr=0 ; # write rendering to file if wr==1 sparsersb(sparsersb(nm),"render",[mn,"-original.eps"]); pct=-time; #p=colamd(nm); p=colperm(nm); pct+=time; pat=-time; nm=nm(:,p); pat+=time; #sparsersb(sparsersb(nm),"render",[mn,"-colamd.eps"]) sparsersb(sparsersb(nm),"render",[mn,"-colperm.eps"]); end fsz=stat(mn).size; rt=toc(); [ia,ja,va]=find(nm); printf("%s: %.2f MBytes read in %.4f s (%10.2f MB/s)\n",mn,fsz/MB,rt,fsz/(rt*MB)); #ia=ia'; ja=ja'; va=va'; sep=" "; csvlstring=sprintf("#mn entries nrows ncols"); csvdstring=sprintf("%%:%s%s%d%s%d%s%d",mn,sep,entries,sep,nrows,sep,ncols); for ski=1:uc oppnz=1; # FIXME: what about handling symmetry ? sparsekw="sparse"; if(ski==2)sparsekw="sparsersb";endif if(ski==3); oppnz=2; sparsekw="sparsersb"; tic(); [nm]=sparsersb(mn); rt=toc(); sparsersb(nm,"info") printf("%s: %.2f MBytes read by librsb in %.4f s (%10.2f MB/s)\n",mn,fsz/MB,rt,fsz/(rt*MB)); endif if(ski==4); nm=tril(nm); endif [ia,ja,va]=find(nm); rnz=nnz(nm); printf(" *** Benchmarking '%s'.\n",sparsekw); # printf("symmetry ? %d\n",issymmetric(sparse(nm))); mrc=rows(nm); mcc=columns(nm); if(ski!=3); tic(); eval(["for i=1:n; om=",sparsekw,"(ia,ja,va,mrc,mcc,\"summation\"); end"]); printf(" *** Benchmarking '%s' instantiation from 'ia,ja,va'.\n",sparsekw); at=toc(); #if(ski==2) tic(); nm=sparsersb(om,"autotune","N");om=nm; att=toc(); ;endif mnz=nnz(om); amflops=n*(mnz/(10^6 * at)); printf("%s '%s' %d Instantiations for %d nnz in %.4f secs, so %10.2f nnz/s\n",mn,sparsekw,n,rnz,at,amflops); else mnz=rnz; end if(ski==2) nsb=str2num(sparsersb(om,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")); printf (" ** Assembled 'sparsersb' matrix has %d RSB blocks.\n", nsb); endif #rm=sparsersb(ia,ja,va);# UNFINISHED r=linspace(1,1,size(om,1))'; v=linspace(1,1,size(om,2))'; printf(" *** Benchmarking '%s' SPMV..\n",sparsekw); tic(); for i=1:n; r+=om *v; end; umt=toc(); UMflops=oppnz*n*2.0*mnz/(10^6 * umt); printf("%s '%s' %d SPMV for %d nnz in %.4f secs, so %10.2f Mflops\n",mn,sparsekw,n,mnz,umt, UMflops); bpnz=-1; # FIXME: bytes per nonzero! msstr="?";# FIXME: matrix structure string! # FIXME: finish the following! #printbenchline(mn',"SPMV",sparsekw,n,mnz,umt, UMflops,bpnz,msstr); # tmp=r;r=v;v=tmp; printf(" *** Benchmarking %s SPMV_T..\n",sparsekw); tic(); for i=1:n; r+=om.'*v; end; tmt=toc(); TMflops=oppnz*n*2.0*mnz/(10^6 * tmt); printf("%s '%s' %d spMVT for %d nnz in %.4f secs, so %10.2f Mflops\n",mn,sparsekw,n,mnz,tmt, TMflops); if(ski<3); csvlstring=sprintf("%s%s",csvlstring," n at amflops umt UMflops tmt TMflops"); csvdstring=sprintf("%s%s%d%s%f%s%f%s%f%s%f%s%f%s%f",csvdstring,sep,n,sep,at,sep,amflops,sep,umt,sep,UMflops,sep,tmt,sep,TMflops); endif disp " " end ++f; # Uncomment following lines for benchmark-oriented output: #printf("%s\n",csvlstring); #printf("%s\n",csvdstring); end disp " ***********************************************************************" endif # nargin > 0 sparsersb-1.0.9/bin/pd.mtx0000644000000000000000000000125314122214045013554 0ustar 00000000000000%%MatrixMarket matrix coordinate real general % a positive definitive matrix, as in % http://www.ncsa.uiuc.edu/UserInfo/Resources/Hardware/IBMp690/IBM/usr/lpp/essl.html.en_US/html/essl43.html % * * % | 99 12 13 14 15 16 | % | 12 99 12 13 14 15 | % | 13 12 99 12 13 14 | % | 14 13 12 99 12 13 | % | 15 14 13 12 99 12 | % | 16 15 14 13 12 99 | % * * 6 6 36 1 1 99 1 2 12 1 3 13 1 4 14 1 5 15 1 6 16 2 1 12 2 2 99 2 3 12 2 4 13 2 5 14 2 6 15 3 1 13 3 2 12 3 3 99 3 4 12 3 5 13 3 6 14 4 1 14 4 2 13 4 3 12 4 4 99 4 5 12 4 6 13 5 1 15 5 2 14 5 3 13 5 4 12 5 5 99 5 6 12 6 1 16 6 2 15 6 3 14 6 4 13 6 5 12 6 6 99 sparsersb-1.0.9/bin/ufsolve.m0000755000000000000000000000620714122214045014267 0ustar 00000000000000# # Copyright (C) 2011-2017 Michele Martone # # 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 . # # # This program shall attempt solution of a problem saved in the MATLAB # format as for the University of Florida collection. # # One with a problem structured as in e.g.: # http://www.cise.ufl.edu/research/sparse/mat/Hamm/memplus.mat # http://www.cise.ufl.edu/research/sparse/mat/Schenk_ISEI/barrier2-9.mat # # s=load("~/barrier2-9.mat"); 1; # This is a script if length(getenv("SPARSERSB_TEST")) == 0 ; pkg load sparsersb ; end disp " ***********************************************************************" disp "** A usage example of sparsersb. **" disp "** You can supply 'sparsersb' matrices to iterative method routines. **" disp "** If the matrix is large enough, this shall secure good performance **" disp "** of matrix-vector multiply: up to you to find method+linear system ! **" disp "** p.s.: Invoke 'demo sparsersb' to get just a first working overview. **" disp " ***********************************************************************" s=load(argv(){length(argv())}); n=rows(s.Problem.A); minres=1e-3; #maxit = n; maxit = 100; b=s.Problem.b; oct_A=sparse(s.Problem.A); rsb_A=sparsersb(s.Problem.A); printf (" **** Loaded a %d x %d matrix with %.3e nonzeroes ****\n", n, columns(s.Problem.A), nnz(s.Problem.A) ); X0=[]; RELRES=2*minres; TOTITER=0; M1=[]; M2=[]; M1=sparse(diag(s.Problem.A)\ones(n,1)); M2=sparse(diag(ones(n,1))); nsb=str2num(sparsersb(rsb_A,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")); printf (" **** The 'sparsersb' matrix consists of %d RSB blocks. ****\n", nsb); disp " *********** Invoking pcg using a 'sparse' matrix ******************* "; tic; [X1, FLAG, RELRES, ITER] = pcg (oct_A, b, minres, maxit, M1,M2,X0); odt=toc; toc disp " *********** Invoking pcg using a 'sparsersb' matrix ******************* "; tic; [X1, FLAG, RELRES, ITER] = pcg (rsb_A, b, minres, maxit, M1,M2,X0); odt=toc; toc disp " ** Attempting autotuning 'sparsersb' matrix (pays off on the long run * "; tic; rsb_A=sparsersb(rsb_A,"autotune","n",1); toc; nsb=str2num(sparsersb(rsb_A,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")); printf (" **** The 'sparsersb' matrix consists of %d RSB blocks now. **** \n", nsb); disp " ****** Invoking pcg using a 'sparsersb' matrix (might be faster now) *** "; tic; [X1, FLAG, RELRES, ITER] = pcg (rsb_A, b, minres, maxit, M1,M2,X0); odt=toc; toc disp " *********************************************************************** "; quit(1); sparsersb-1.0.9/doc/README0000644000000000000000000000316014122214045013273 0ustar 00000000000000 ================================================================================ This (sparsersb) is a plugin to interface the "librsb" high performance sparse matrix library to GNU Octave. Author: Michele MARTONE ================================================================================ Build / use instructions (using pkg): To use the configure auto-detected librsb from within Octave: > pkg -local -verbose install sparsersb-1.0.9.tar.gz > pkg load sparsersb > help sparsersb Alternatively: tar czf sparsersb-1.0.9.tar.gz cd sparsersb-1.0.9/src ./configure make make check It is possible to provide the configure script with a librsb sources archive you have downloaded separately and make it build on the fly for you and use it; e.g.: ./configure --with-librsb-tarball=$HOME/librsb-1.2.0.10.tar.gz or setting: export LIBRSB_TARBALL=$HOME/librsb-1.2.0.10.tar.gz before entering in Octave and building with pkg: > pkg -local -verbose install sparsersb-1.0.9.tar.gz On many systems, you will have to build librsb with the PIC (-fPIC on GCC) option or you will get link-time problems. More configure options: ./configure --help Usage instructions without using pkg: # go to the directory where sparsersb.oct is located and run Octave: octave # you can use the sparsersb function, starting with e.g.: > help sparsersb Check out http://librsb.sf.net for the latest librsb release, http://octave.sourceforge.net/sparsersb/ for the latest sparsersb release and http://hg.code.sf.net/p/octave/sparsersb/ for the latest repository version. ================================================================================ sparsersb-1.0.9/doc/sparsersb.txt0000644000000000000000000001254214122214045015164 0ustar 00000000000000 -- Loadable Function: S = sparsersb (A) -- Loadable Function: S = sparsersb (I, J, SV, M, N) -- Loadable Function: S = sparsersb (I, J, SV, M, N, NZMAX) -- Loadable Function: S = sparsersb (I, J, SV) -- Loadable Function: S = sparsersb (M, N) -- Loadable Function: S = sparsersb (I, J, SV, M, N, "unique") -- Loadable Function: sparsersb ("set", OPN, OPV) -- Loadable Function: V = sparsersb (S, "get", MIF) -- Loadable Function: V = sparsersb (S, QS) -- Loadable Function: sparsersb (A,"save",MTXFILENAME) -- Loadable Function: [S, NROWS, NCOLS, NNZ, REPINFO, FIELD, SYMMETRY] = sparsersb (MTXFILENAME[, MTXTYPESTRING]) -- Loadable Function: sparsersb (S,"render", FILENAME[, RWIDTH, RHEIGHT]) -- Loadable Function: [O =] sparsersb (S,"autotune"[, TRANSA, NRHS, MAXR, TMAX, TN, SF]) Create or manipulate sparse matrices using the RSB format provided by librsb, as similarly as possible to `sparse'. If A is a full matrix, convert it to a sparse matrix representation, removing all zero values in the process. Given the integer index vectors I and J, and a 1-by-`nnz' vector of real or complex values SV, construct the sparse matrix `S(I(K),J(K)) = SV(K)' with overall dimensions M and N. The argument `NZMAX' is ignored but accepted for compatibility with MATLAB and `sparsersb'. If M or N are not specified their values are derived from the maximum index in the vectors I and J as given by `M = max (I)', `N = max (J)'. Can load a matrix from a Matrix Market matrix file named MTXFILENAME. The optional argument MTXTYPESTRING can specify either real ("D") or complex ("Z") type. Default is real. In the case MTXFILENAME is "?", a string listing the available numerical types with BLAS-style characters will be returned. If the file turns out to contain a Matrix Market dense vector, this will be loaded. If "save" is specified, saves a sparse RSB matrix as a Matrix Market matrix file named MTXFILENAME. *Note*: if multiple values are specified with the same I, J indices, the corresponding values in SV will be added. The following are all equivalent: s = sparsersb (i, j, s, m, n) s = sparsersb (i, j, s, m, n, "summation") s = sparsersb (i, j, s, m, n, "sum") If the optional "unique" keyword is specified, then if more than two values are specified for the same I, J indices, only the last value will be used. `sparsersb (M, N)' will create an empty MxN sparse matrix and is equivalent to `sparsersb ([], [], [], M, N)'. If M or N are not specified, then `M = max (I)', `N = max (J)'. If OPN is a string representing a valid librsb option name and OPV is a string representing a valid librsb option value, these will be passed to the `rsb_lib_set_opt_str()' function. If MIF is a string specifying a valid librsb matrix info string (valid for librsb's `rsb_mtx_get_info_from_string()'), then the corresponding value will be returned for matrix `S', in string `V'. If MIF is the an empty string (""), matrix structure information will be returned. As of librsb-1.2, these is debug or internal information. E.g. for 'RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T', a string with the count of internal RSB blocks will be returned. If S is a sparsersb matrix and QS is a string, QS shall be interpreted as a query string about matrix S. String `V' will be returned with query results. *Note*: this feature is to be completed and its syntax reserved for future use. In this version, whatever the value of QS, a general matrix information string will be returned (like sparsersb(S,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T") ). If S is a sparsersb matrix and the "render" keyword is specified, and FILENAME is a string, A will be rendered as an Encapsulated Postscript file FILENAME. Optionally, width and height can be specified in `RWIDTH, RHEIGHT'. Defaults are 512. If S is a sparsersb matrix and the "autotune" keyword is specified, autotuning of the matrix will take place, with SpMV and autotuning parameters. After the "autotune" string, the remaining parameters are optional. Parameter TRANSA specifies whether to tune for untransposed ("N") or transposed ("T"); NRHS the number of right hand sides; MAXR the number of tuning rounds; TMAX the threads to use. If giving an output argument O, that will be assigned to the autotuned matrix, and the input one A will remain unchanged. See librsb documentation for `rsb_tune_spmm' to learn more. Long (64 bit) index support is partial: if Octave has been configured for 64 bit indices, sparsersb will correctly handle and convert matrices/indices that would fit in a 32 bit indices setup, failing on 'larger' ones. Please note that on `sparsersb' type variables are available most, but not all of the operators available for `full' or `sparse' typed variables. See also: full, sparse. Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. sparsersb-1.0.9/inst/matlabbench.m0000644000000000000000000000372714122214045015252 0ustar 00000000000000# # Copyright (C) 2011-2015 Michele Martone # # 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 . # # Undocumented # function mbench(fname) function matlabbench(fname) addpath ext/ mp=matlabpath(); n=10; for f=1:nargin MB=1024*1024; mmn=fname'; mn=strtrim(mmn'); tic(); matlabpath('ext'); mn; nm=mmreadm(mn); matlabpath(mp); %fsz=stat(mn).size; rnz=nnz(nm); rt=toc(); [ia,ja,va]=find(nm); %printf('%s: %.2f MBytes read in %.4f s (%10.2f MB/s)\n',mn',fsz/MB,rt,fsz/(rt*MB)); %ia=ia'; ja=ja'; va=va'; for ski=1:1 % FIXME: what about symmetry ? sparsekw='sparse'; if(ski==2)sparsekw='sparsersb';end tic(); for i=1:n; om=sparse(ia,ja,va); end at=toc(); mnz=nnz(om); amflops=n*2.0*mnz/(10^6 * at); %printf('%s (%s) %d spBLD for %d nnz in %.4f secs, so %10.2f Mflops\n',mn',sparsekw,n,rnz,at,amflops); amflops %rm=sparsersb(ia,ja,va);% UNFINISHED v=linspace(1,1,size(om,1))'; r=v; tic(); for i=1:n r=r+om*v; end ; umt=toc(); UMflops=n*2.0*mnz/(10^6 * umt); UMflops %printf('%s (%s) %d spMV for %d nnz in %.4f secs, so %10.2f Mflops\n',mn',sparsekw,n,mnz,umt, UMflops); tic(); for i=1:n r=r+om.'*v; end ; tmt=toc(); TMflops=n*2.0*mnz/(10^6 * tmt); TMflops %printf('%s (%s) %d spMV for %d nnz in %.4f secs, so %10.2f Mflops\n',mn',sparsekw,n,mnz,tmt, TMflops); end end %printf('benchmark terminated successfully\n'); quit end sparsersb-1.0.9/inst/sparsersbbench.m0000755000000000000000000001347514122214045016022 0ustar 00000000000000#!/usr/bin/octave -q # # Copyright (C) 2011-2016 Michele Martone # # 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 . # # TODO: document this file's functions so they get installed and are properly usable. # TODO: sprand should not be used in a consistent way 1; # This is a script. if length(getenv("SPARSERSB_TEST")) == 0 ; pkg load sparsersb ; end function dt=sparsersbbench__(precmd,cmd,postcmd,mint) # .. eval(precmd); nops=0; tic(); do ++nops; eval(cmd); until ((dt=toc())>=mint) dt/=nops; eval(postcmd); end function speedup=sparsersbbench_(gprecmd,precmd,cmd,postcmd,gpostcmd,mint) # ... rprecmd=strrep(precmd,"sparsersb","sparse"); rcmd=strrep(cmd,"sparsersb","sparse"); rpostcmd=strrep(postcmd,"sparsersb","sparse"); dots=";"; once=[precmd,dots,cmd,dots,postcmd]; #eval(once); printf("iterating %s\n",once); # dots="..."; predots=sprintf(";tic;do;"); postdots=sprintf(";until ((dt=toc())>=%f);",mint); all=[gprecmd,dots,precmd,predots,cmd,postdots,postcmd,dots,gpostcmd]; # printf("will see speedup for %s\n",all); printf("#%s #-> speedup is...",all); dtr=sparsersbbench__([gprecmd,"", precmd,""], cmd,[ postcmd,":",gpostcmd],mint); dto=sparsersbbench__([gprecmd,"",rprecmd,""],rcmd,[rpostcmd,":",gpostcmd],mint); speedup=dto/dtr; printf("%.2f\n",speedup); # printf("%.2f speedup for %s\n",speedup,all); end function sparsersbbench_battery(mstring,mint) rinitstr=["A=sparsersb(",mstring,");nr=size(A)(1);nc=size(A)(2);"]; finitstr=["A=full(",mstring,");"]; cinitstr=["M=sparse(",mstring,");[ia,ja,va]=find(M);nr=size(M)(1);nc=size(M)(2);"]; sparsersbbench_("",[rinitstr,""],"A.*=2.0;","clear A","",mint); sparsersbbench_("",[rinitstr,""],"A.*=2.5;","clear A","",mint); sparsersbbench_("",[rinitstr,""],"A./=2.0;","clear A","",mint); sparsersbbench_("",[rinitstr,""],"A./=2.5;","clear A","",mint); #sparsersbbench_("",[rinitstr,""],"A.*=0.0;","clear A","",mint); #sparsersbbench_("",[rinitstr,""],"A./=0.0;","clear A","",mint); sparsersbbench_("",[rinitstr,""],"A.^=2.5;","clear A","",mint); sparsersbbench_("",[rinitstr,""],"A.^=2.0;","clear A","",mint); sparsersbbench_("",[rinitstr,""],"A.^=0.5;","clear A","",mint); sparsersbbench_("",[cinitstr,""],"C=sparsersb(ia,ja,va,nr,nc);clear C;","clear A C ia ja va","",mint); sparsersbbench_("",[cinitstr,""],"C=sparsersb(ia,ja,va);clear C;","clear A C ia ja va","",mint); sparsersbbench_("",[cinitstr,""],"C=sparsersb(ja,ia,va);clear C;","clear A C ia ja va","",mint); sparsersbbench_("",[finitstr,""],"C=sparsersb(A);clear C;","clear A C","",mint); sparsersbbench_("",[rinitstr,""],"C=A; ;clear C;","clear A C","",mint); sparsersbbench_("",[rinitstr,""],"C=A.'; ;clear C;","clear A C","",mint); sparsersbbench_("",[rinitstr,""],"C=transpose(A);clear C;","clear A C","",mint); for nrhs=1:3 nrhss=sprintf("%d",nrhs); sparsersbbench_("",[rinitstr,"C=ones(nr,",nrhss,");B=C;"],"C=A*B;","clear A B C","",mint); sparsersbbench_("",[rinitstr,"C=ones(nr,",nrhss,");B=C;"],"C=A.'*B;","clear A B C","",mint); eval(finitstr); if (tril(A)==A) || (triu(A)==A) sparsersbbench_("",[rinitstr,"C=ones(nr,",nrhss,");B=C;"],"C=A\\B;","clear A B C","",mint); sparsersbbench_("",[rinitstr,"C=ones(nr,",nrhss,");B=C;"],"C=A.'\\B;","clear A B C","",mint); end end clear A; sparsersbbench_("",[rinitstr,"D=ones(nr,1);"],"D=diag(A);","clear A D","",mint); sparsersbbench_("",[rinitstr,"B=A;"],"C=A+B;","clear A B C","",mint); sparsersbbench_("",[rinitstr,"B=A;"],"C=A.'+B;","clear A B C","",mint); sparsersbbench_("",[rinitstr,"B=A;"],"C=A*B;clear C","clear A B C","",mint); sparsersbbench_("",[rinitstr,"B=A;"],"C=A.'*B;clear C","clear A B C","",mint); end btime=1.0; if false ; # shall use: [x, flag, prec_res_norm, itcnt] sparsersbbench_("n=1000; k=15; oA=k*eye(n)+sprandn(n,n,.2); b=ones(n,1); P=diag(diag(oA));","A=sparsersb(oA);","[x, flag] = gmres (A, b, [], 1e-7, n, P);","clear b P","clear oA",btime); sparsersbbench_("n=2000; k=150; oA=k*eye(n)+sprandn(n,n,.2); b=ones(n,1); P=diag(diag(oA));","A=sparsersb(oA);","[x, flag] = gmres (A, b, [], 1e-7, n, P);","clear b P","clear oA",btime); sparsersbbench_("n=4000; k=1500; oA=k*eye(n)+sprandn(n,n,.2); b=ones(n,1); P=diag(diag(oA));","A=sparsersb(oA);","[x, flag] = gmres (A, b, [], 1e-7, n, P);","clear b P","clear oA",btime); sparsersbbench_("n=6000; k=3500; oA=k*eye(n)+sprandn(n,n,.2); b=ones(n,1); P=diag(diag(oA));","A=sparsersb(oA);","[x, flag] = gmres (A, b, [], 1e-7, n, P);","clear b P","clear oA",btime); end #for diml=0:0 for diml=1:11 #for diml=11:11 #for diml=3:3 #for cadd=1:1 #for cadd=0:0 for cadd=0:1 btime=1.0; if(diml<7)btime=0.1;end dim=2^diml; #is=sprintf("ones(%d)",dim); cmul=sprintf("(1+i*%d)",cadd); is=sprintf("ones(%d).*%s",dim,cmul); sparsersbbench_battery(is,btime) is=sprintf("tril(ones(%d).*%s)",dim,cmul); sparsersbbench_battery(is,btime) is=sprintf("diag(ones(%d,1)).*%s",dim,cmul); sparsersbbench_battery(is,btime) # FIXME: follow non repeatable experiments :) is=sprintf("(diag(ones(%d,1))+sprand(%d,%d,0.1)).*%s",dim,dim,dim,cmul); sparsersbbench_battery(is,btime) is=sprintf("(diag(ones(%d,1))+sprand(%d,%d,0.4)).*%s",dim,dim,dim,cmul); sparsersbbench_battery(is,btime) # FIXME: need a non-square matrices testing-benchmarking snippet end end printf "All done." sparsersb-1.0.9/inst/sparsersbtester.m0000644000000000000000000003410714122214045016241 0ustar 00000000000000#!/usr/bin/octave -q # # Copyright (C) 2011-2019 Michele Martone # # 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 . # # # A comparative tester for sparsersb. # # TODO: # # - shall integrate with the rsb.m tester # - isequal(find(a),find(b)) only checks for pattern! # - isequal(sparsersb(..),sparsersb(..)) is unfinished ! # - need NZMAX as last arg testing # - in sparsersb, the == operator is not yet handled natively # - need testing for find(M,?) # - seems like non-square matrices are not tested # - shall test +-, &=, --, ++, .', ./, .\, /, -, +, .*, ./, .^, +0, ==, <=, >=, >, <, |, & # 1; # This is a script. function error_if(cond) if(cond) error "octave's sparse and sparsersb seem not to match" end end # error_if function ast=are_same_type(OM,XM) ast=(strcmp(typeinfo(OM), typeinfo(XM)) == 1); # Octave's strcmp returns 1 if same. end # are_same_type function ase=are_spm_equal(OM,XM,eoin) ase=0; if(nargin>=3) eoi=eoin; else eoi=false; end if(nnz(XM)!=nnz(OM)); error_if(eoi); return; end if(columns(XM)!=columns(OM)); error_if(eoi); return; end if(rows(XM)!=rows(OM)); error_if(eoi); return; end if(length(XM)!=length(OM)); error_if(eoi); return; end if(size(XM)!=size(OM)); error_if(eoi); return; end if(full(XM)!=full(OM)); error_if(eoi); return; end if((3*XM)!=(3*OM)); error_if(eoi); return; end if((XM*3)!=(OM*3)); error_if(eoi); return; end if((XM*i)!=(OM*i)); error_if(eoi); return; end if((i*XM)!=(i*OM)); error_if(eoi); return; end if((XM/2)!=(OM/2)); error_if(eoi); return; end if((XM/i)!=(OM/i)); error_if(eoi); return; end if((XM' )!=(OM' )); error_if(eoi); return; end if(conj(XM)!=conj(OM)); error_if(eoi); return; end if(transpose(XM)!=transpose(OM)); error_if(eoi); return; end #if((XM.^(2+0*i))!=(OM.^(2+0*i))); error_if(eoi); return; end if((XM.^(0+2*i))!=(OM.^(0+2*i))); error_if(eoi); return; end if((XM.^(2+0*i))!=(OM.^(2+0*i))) errn=norm((XM.^2)-(OM.^2)); if (errn<1e-13); (XM.^2) (OM.^2) warning ("tiny mismatch (norm: %g) when computing matrix squares (see above)", double(errn)); else error_if(eoi); return; end end if((-XM)!=(-OM)); error_if(eoi); return; end for ri=1:rows(XM) if(XM(ri,:)!=OM(ri,:)); error_if(eoi); return; end end for ci=1:columns(XM) if(XM(:,ci)!=OM(:,ci)); error_if(eoi); return; end end for ri=1:rows(XM) for ci=1:columns(XM) if(XM(ri,ci)!=OM(ri,ci)); error_if(eoi); return; end end end if(XM(:,:)!=OM(:,:)); error_if(eoi); return; end ase=1; [oi,oj,ov]=find(OM); [xi,xj,xv]=find(XM); ise =isequal(oi,xi); error_if(eoi && !ise); ase&=ise; ise =isequal(oj,xj); error_if(eoi && !ise); ase&=ise; ise =isequal(ov,xv); error_if(eoi && !ise); ase&=ise; return; end # are_spm_equal function testmsg(match,tname,erreason) if(match>0) printf(" [*] %s test passed",tname) elseif(match==0) printf(" [!] %s test failed",tname) else printf(" [~] %s ",tname) end if(nargin<3) printf(".\n") else printf(" ().\n",erreason) end end # testmsg function match=testinfo(OM,XM) printf("will test types \"%s\" and \"%s\"\n",typeinfo(OM),typeinfo(XM)) match=1; end # testinfo function match=testdims(OM,XM) match=1; match&=(rows(OM)==rows(XM)); match&=(columns(OM)==columns(XM)); match&=(nnz(OM)==nnz(XM)); testmsg(match,"dimensions"); end # testdims function match=testsprsb(OM,XM) match=1; # FIXME: shall see in detail whether there are not too many conversions here.. [oi,oj,ov]=find(OM); RM=sparsersb(oi,oj,ov); match&=isequal(find(RM),find(OM)); match&=isequal(find(RM),find(XM)); clear RM; RM=sparsersb(oi,oj,ov,size(OM)(1),size(OM)(2)); match&=isequal(find(RM),find(OM)); match&=isequal(find(RM),find(XM)); clear RM; RM=sparsersb(full(OM)); match&=isequal(find(RM),find(OM)); match&=isequal(find(RM),find(XM)); clear RM; RM=sparsersb([oi;1;1],[oj;1;1],[ov;-1;1]); match&=isequal(find(RM),find(OM)); match&=isequal(find(RM),find(XM)); clear RM; nr=max(oi); nc=max(oj); RM=sparsersb([oi;1;1],[oj;1;1],[ov;-1;1],nr,nc,"sum") match&=are_spm_equal(RM,OM,true); match&=are_spm_equal(RM,XM,true); clear RM; RM=sparsersb([oi;1;1],[oj;1;1],[ov;-2;1],nr,nc,"sum"); match&=!are_spm_equal(RM,OM); match&=!are_spm_equal(RM,XM); clear RM; RM=sparsersb([oi;nr+1;nr+1],[oj;nc+1;nc+1],[ov;-1;1],nr+1,nc+1,"unique"); match&=!are_spm_equal(RM,OM); match&=!are_spm_equal(RM,XM); clear RM; testmsg(match,"constructors"); end # testsprsb function match=testfind(OM,XM) match=1; match&=isequal(find(OM),find(XM)); match&=isequal(([oi,oj]=find(OM)),([xi,xj]=find(XM))); match&=isequal(([oi,oj,ov]=find(OM)),([xi,xj,xv]=find(XM))); match&=isequal(nonzeros(OM),nonzeros(XM)); testmsg(match,"find"); end # testfind function match=testasgn(OM,XM) match=1; nr=rows(OM); nc=columns(OM); for i=1:nr for j=1:nc #printf("%d %d / %d %d\n", i,j,nr,nc) #OM, XM #printf("%d %d %d\n", i,j,XM(i,j)); if(XM(i,j)) nv=rand(1); OM(i,j)=nv; XM(i,j)=nv; end #OM, XM #exit endfor endfor for i=1:nr for j=1:nc if(OM(i,j))match&=isequal(OM(i,j),XM(i,j)); end; endfor endfor testmsg(match,"asgn"); end # testasgn function match=testelms(OM,XM) match=1; nr=rows(OM); nc=columns(OM); for i=1:nr for j=1:nc if(OM(i,j)!=XM(i,j)); match*=0; end endfor endfor testmsg(match,"elems"); end # testelms function match=testdiag(OM,XM) #sparse(spdiag(OM)) #sparse(spdiag(XM)) #match=(sparse(spdiag(OM))==sparse(spdiag(XM))) #OM,XM #diag(OM) #diag(XM) match=1; if(diag(OM)==diag(XM));match=1;else match=0;end #match=(diag(OM)==diag(XM)); # TODO: understand why the following syntax is problematic ! #match=(spdiag(OM)==spdiag(XM)); testmsg(match,"diagonal"); end # testdiag function match=testpcgm(OM,XM) # FIXME! This test ignores OM and XM ! match=1; tol=1e-10; A=sparse ([11,12;21,23]);X=[11;22];B=A*X;X=[0;0]; [OX, OFLAG, ORELRES, OITER, ORESVEC, OEIGEST]=pcg(A,B); A=sparsersb([11,12;21,23]);X=[11;22];B=A*X;X=[0;0]; [XX, XFLAG, XRELRES, XITER, XRESVEC, XEIGEST]=pcg(A,B); match&=(OFLAG==XFLAG);# FIXME: a very loose check! match&=(OITER==XITER);# FIXME: a very loose check! # # http://www.gnu.org/software/octave/doc/interpreter/Iterative-Techniques.html#Iterative-Techniques #n = 10; n = 10+size(XM)(1,1) clear A OX XX; A = diag (sparse (1:n)); #A = A + A'; b = rand (n, 1); opts.droptol=1.e-3; [l, u] = ilu (A); [OX, OFLAG, ORELRES, OITER, ORESVEC, OEIGEST]= pcg ( A ,b); [XX, XFLAG, XRELRES, XITER, XRESVEC, XEIGEST]= pcg (sparsersb(A),b); match&=(norm(OX-XX)2) M endif match=1; if nnz(OM)>0 match&=testsprsb(OM,XM); end match&=testinfo(OM,XM); match&=testdims(OM,XM); match&=testdiag(OM,XM); match&=testfind(OM,XM); match&=testelms(OM,XM); match&=testasgn(OM,XM); if nnz(OM)>1 if have_working_ilu() match&=testpcgm(OM,XM); match&=testpcrm(OM,XM); else testmsg(-1,"ilu does not work; probably UMFPACK is not installed: skipping some tests.") endif match&=testmult(OM,XM); match&=testspsv(OM,XM); match&=testnorm(OM,XM); end match&=testscal(OM,XM); match&=testadds(OM,XM); testmsg(match,"overall (for this matrix)"); end # tests match=1; mtn=1; if (strchr(sparsersb("?"),"Z")>0) mtn++; endif for mti=1:mtn wc=(mti==2); dim=3; #M=(rand(dim)>.8)*rand(dim);M(1,1)=11; M=[0]; OM=sparse(M); XM=sparsersb(M); match&=tests(OM,XM); for k=1:6 M=[eye(k)]; if(wc)M+=M*i;end OM=sparse(M); XM=sparsersb(M); match&=tests(OM,XM,M); end #M=zeros(4)+sparse([1,2,3,2,4],[1,2,3,1,4],[11,22,33,21,44]); #if(wc)M+=M*i;end #OM=sparse(M); XM=sparsersb(M); #match&=tests(OM,XM); for k=3:6 M=zeros(k)+sparse([linspace(1,k,k),2],[linspace(1,k,k),1],[11*linspace(1,k,k),21]); if(wc)M+=M*i;end OM=sparse(M); XM=sparsersb(M); match&=tests(OM,XM); end #M=tril(ones(10))+100*diag(10); #OM=sparse(M); XM=sparsersb(M); #match&=tests(OM,XM); #M=hilb(10)+100*diag(10); #OM=sparse(M); XM=sparsersb(M); #match&=tests(OM,XM); M=diag(10); if(wc)M+=M*i;end OM=sparse(M); XM=sparsersb(M); match&=tests(OM,XM); #M=diag(10)+sparse([1,10],[10,10],[.1,1]); #OM=sparse(M); XM=sparsersb(M); #match&=tests(OM,XM); end function sparse_sparse_update_test() A=sparsersb([11,0,0;0,22,23;0,0,0]) O=sparse(A) if A(1,1)!=O(1,1) error "subsref seemingly not working!" endif if (A!=0) != (O!=0) error "subsasgn seemingly not working!" endif A(A==23)=222 O(O==23)=222 if A != O error "subsasgn seemingly not working!" endif return # Not yet there: A(sparsersb([0,0,0;1,0,0;0,0,0]))=-99 # not in nnz pattern A(sparsersb([0,0,0;1,0,0;0,0,0]))=-99*i # only double supported for the moment end # endfunction sparse_sparse_update_test() if(match) printf("All tests passed.\n"); else printf("Failure while performing tests!\n");end # FIXME: shall print a report in case of failure. #M=zeros(3)+sparse([1,2,3],[1,2,3],[11,22,33]); #M=sparse([1,2,3],[1,2,3],[11,22,33]); #XM=sparsepsb(M); # # # exit # # XM # find(XM) # [i,j]=find(XM) # # exit # sparsersb-1.0.9/src/Makeconf.in0000644000000000000000000000035414122214045014512 0ustar 00000000000000OCTAVE = @OCTAVE@ CXXFLAGS = @CXXFLAGS@ MKOCTFILE = @MKOCTFILE@ -v SPARSERSB_CXXFLAGS = @SPARSERSB_CXXFLAGS@ SPARSERSB_LDFLAGS = @SPARSERSB_LDFLAGS@ SPARSERSB_CXX11= @SPARSERSB_CXX11@ OCTAVE_FUNC_DEFINES = @HAVE_OCTAVE_VALUE_ISCOMPLEX@ sparsersb-1.0.9/src/Makefile0000644000000000000000000001147014122214045014100 0ustar 00000000000000# # Copyright (C) 2011-2021 Michele Martone # # 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 . # sinclude Makeconf # Makeconf is created by the configure script. # You can also not use it but set explicitly the following: CXXFLAGS=$(SPARSERSB_CXXFLAGS) $(OCTAVE_FUNC_DEFINES) LDFLAGS=$(shell $(MKOCTFILE) -p LDFLAGS) $(SPARSERSB_LDFLAGS) CXXFLAGS_CXX11=$(SPARSERSB_CXX11) .PHONY: all check SPARSERSB_OCT=sparsersb.oct all: $(SPARSERSB_OCT) tags: *.cc ctags * #library: # true # if test "$(RSBLIBDIR)" = $(shell pwd)/../lib ; then \ # # echo "Will build librsb so to have RSBINCDIR=$(RSBINCDIR) and RSBLIBDIR=$(RSBLIBDIR)"; \ # # make -C $(RSBLIBDIR) ; fi $(SPARSERSB_OCT): sparsersb.cc LFLAGS="$(LDFLAGS)" LDFLAGS="$(LDFLAGS)" CXXFLAGS="$(CXXFLAGS) $(CXXFLAGS_CXX11)" $(MKOCTFILE) -D'RSB_SPARSERSB_LABEL=sparsersb' -o $@ $< rtest: $(SPARSERSB_OCT) SPARSERSB_TEST=1 $(OCTAVE) --norc --silent ../inst/sparsersbtester.m SPARSERSB_TEST=1 $(OCTAVE) --norc --silent ../bin/octavebench.m ../bin/pd.mtx SPARSERSB_TEST=1 $(OCTAVE) --norc --silent ../bin/octavebench.m SPARSERSB_TEST=1 $(OCTAVE) --norc --silent --eval 'exit( ! test("sparsersb") )' # only meaningful for the developer devtests: SPARSERSB_TEST=1 $(OCTAVE) --norc --silent --eval 'exit( ! test("sparsersbtg") )' bench: $(SPARSERSB_OCT) SPARSERSB_TEST=1 $(OCTAVE) --norc --silent ../bin/obench.m SPARSERSB_TEST=1 $(OCTAVE) --norc --silent ../bin/lsbench.m SPARSERSB_TEST=1 $(OCTAVE) --norc --silent ../inst/sparsersbbench.m itests: tests SPARSERSB_TEST=1 $(OCTAVE) --norc --silent --eval 'demo sparsersb' tests: rtest check: tests clean: -$(RM) *.o octave-core core *.oct *~ tags srut: awk -f srut.awk < sparsersb.cc > sparsersb.cc.new mv sparsersb.cc.new sparsersb.cc # This is expected to work on author's machine. #dist_old: # echo "warning: we are making a tarball out of SVN repositories: NOT this checked out copy." # rm -fR $(PACKAGE_NAME) # svn export `svn info | grep URL | sed 's/^.* //;s/src$$//'g` $(PACKAGE_NAME) # cd $(PACKAGE_NAME)/src && sh autogen.sh && cd - # rm -fR $(PACKAGE_NAME)/src/old # rm -fR $(PACKAGE_NAME)/src/TODO.txt # rm -fR $(PACKAGE_NAME)/src/oldjunk # tar czf $(PACKAGE_NAME).tgz $(PACKAGE_NAME) # tar tzf $(PACKAGE_NAME).tgz SPARSERSB=sparsersb-1.0.9 ARCHIVE=$(HOME)/src/sparsersb-archives GPGSIGNCMD=gpg -sbav -u 1DBB555AEA359B8AAF0C6B88E0E669C8EF1258B8 help: @echo "# As a user, './configure ... .; make;' shall suffice." @echo "# If you are developing, you might be interested in 'make' followed by either of dist, sdist, sign, tarballs, html-doc." dist: tarballs html-doc sdist: sign tarballs html-doc sign: tarballs html-doc $(GPGSIGNCMD) $(ARCHIVE)/$(SPARSERSB).tar.gz gpg --verify $(ARCHIVE)/$(SPARSERSB).tar.gz.asc $(GPGSIGNCMD) $(ARCHIVE)/sparsersb-html.tar.gz gpg --verify $(ARCHIVE)/sparsersb-html.tar.gz.asc tarballs: rm -f $(ARCHIVE)/$(SPARSERSB).tar hg archive -t tar $(ARCHIVE)/$(SPARSERSB).tar --exclude '*.hgignore' -X ".hg*" rm -f ../../$(SPARSERSB) ln -s `pwd`/.. ../../$(SPARSERSB) cd ../.. && tar rf $(ARCHIVE)/$(SPARSERSB).tar --add-file $(SPARSERSB)/src/configure cd ../.. && tar f $(ARCHIVE)/$(SPARSERSB).tar \ --delete $(SPARSERSB)/.hg_archival.txt --delete $(SPARSERSB)/.hgtags --delete $(SPARSERSB)/.hgignore #tar tvf $(SPARSERSB).tar gzip -f $(ARCHIVE)/$(SPARSERSB).tar tar tvzf $(ARCHIVE)/$(SPARSERSB).tar.gz html-doc: rm -fR ./octfiles-tmp ./sparsersb-html $(SPARSERSB) mkdir -p ./octfiles-tmp #tar xvzf $(ARCHIVE)/$(SPARSERSB).tar.gz # If missing.. pkg install -forge generate_html $(OCTAVE) --norc --eval 'pkg prefix ./octfiles-tmp ; echo on; diary sparsersb-diary-install.log; more off; pkg install -verbose '$(ARCHIVE)/$(SPARSERSB).tar.gz'; echo off; pkg load generate_html; generate_package_html ("sparsersb", "sparsersb-html", "octave-forge")' tar czf $(ARCHIVE)/sparsersb-html.tar.gz sparsersb-html echo "You maybe want to remove dirs: ./octfiles-tmp ./sparsersb-html $(SPARSERSB)" ls -l $(ARCHIVE)/sparsersb-html.tar.gz $(ARCHIVE)/$(SPARSERSB).tar.gz md5sum $(ARCHIVE)/sparsersb-html.tar.gz $(ARCHIVE)/$(SPARSERSB).tar.gz cd $(ARCHIVE)/ doc: $(SPARSERSB_OCT) $(OCTAVE) --norc -q --eval 'help sparsersb' | grep -v 'is a function from the' > ../doc/sparsersb.txt sparsersb-1.0.9/src/autogen.sh0000755000000000000000000000002414122214045014432 0ustar 00000000000000#! /bin/sh autoconf sparsersb-1.0.9/src/configure.ac0000644000000000000000000002231014122214045014721 0ustar 00000000000000# # Copyright (C) 2011-2021 Michele Martone # # 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 . # # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.67]) AC_INIT([octave sparsersb package], [1.0.9]) dnl AC_CONFIG_HEADERS([config.h]) # Checks for programs. AC_PROG_CXX AC_LANG(C++) AC_CHECK_TOOL([OCTAVE], [octave], [none]) AC_CHECK_TOOL([MKOCTFILE], [mkoctfile], [none]) AC_ARG_VAR([MKOCTFILE],[The mkoctfile executable]) AC_ARG_VAR([OCTAVE],[The octave executable]) AC_ARG_VAR([SPARSERSB_LDFLAGS],[Linking flags for sparsersb]) AC_ARG_VAR([SPARSERSB_CXXFLAGS],[C++ compilation flags for sparsersb]) AC_ARG_VAR([SPARSERSB_CXX11],[C++11 additional compilation flags for sparsersb]) AC_ARG_VAR([LIBRSB_TARBALL],[Environment variable equivalent for --with-librsb-tarball=..]) if [ test "$MKOCTFILE" = "none" ]; then AC_MSG_ERROR([mkoctfile required to install $PACKAGE_NAME]) fi MKOCTFILE="$MKOCTFILE -g" # Checks for librsb have_rsb=no librsb_conf='no' librsb_conf_static='no' # internal AC_ARG_WITH(static-librsb, [ --with-static-librsb=[yes|no] Whether to use static linking with the librsb-conf script. (recommended: yes).], [ librsb_conf_static=$withval; if x"$librsb_conf_static" != xyes -a x"$librsb_conf_static" != xno ; then AC_MSG_ERROR([--static-librsb=yes or --static-librsb=no !! ]) fi ], [ ]) # BEGIN tarball-based on-the-fly install of librsb AC_ARG_WITH(librsb-tarball, [ --with-librsb-tarball=... Will use specified user provided librsb tarball (e.g. librsb-1.2.0.tar.gz) to build a local librsb installation. You can specify LIBRSB_CFLAGS to customize. With this option --with-librsb-conf will be ignored.], [ librsb_tarball=$withval ], [ librsb_tarball=no ]) if [ test x"$LIBRSB_TARBALL" != "x" ]; then AC_MSG_NOTICE([Detected user-set LIBRSB_TARBALL=... variable; equivalent to --with-librsb-tarball=... .]) librsb_tarball="$LIBRSB_TARBALL" else AC_MSG_NOTICE([No user-set LIBRSB_TARBALL environment variable detected (set it to build using a custom librsb tarball).]) fi if test x"$librsb_tarball" != x"no" ; then dnl AC_MSG_WARN([...]) AC_MSG_NOTICE([Will create a local librsb build from user provided "$librsb_tarball" tarball. Will use default LIBRSB_CFLAGS.]) test -f ${librsb_tarball} || AC_MSG_ERROR([Are you sure of having file $librsb_tarball ?]) tar xzf "$librsb_tarball" || AC_MSG_ERROR([Error uncompressing "$librsb_tarball" ?]) librsb_dir=`basename $librsb_tarball` librsb_dir=${librsb_dir/.tar.gz/} test -d "$librsb_dir" || AC_MSG_ERROR([Error accessing "$librsb_dir" -- are you sure you provided a valid librsb tarball ?]) dnl LIBRSB_PREFIX="${LIBRSB_PREFIX:-`pwd`/local}" LIBRSB_PREFIX="`pwd`/local" cd "$librsb_dir" || AC_MSG_ERROR([Error entering "$librsb_dir" -- are you sure you provided a valid librsb tarball ?]) # LIBRSB_CFLAGS="${LIBRSB_CFLAGS:--O3 -fPIC}" AC_MSG_NOTICE([Stepped in "$librsb_dir".]) dnl AC_MSG_NOTICE([Configuring with LIBRSB_PREFIX=$LIBRSB_PREFIX ]) AC_MSG_NOTICE([Configuring with LIBRSB_CFLAGS=$LIBRSB_CFLAGS ]) ./configure OCTAVE='false' CFLAGS="${LIBRSB_CFLAGS}" --prefix="${LIBRSB_PREFIX}" --disable-fortran-examples --disable-c-examples AC_MSG_NOTICE([Configured successfully.]) make || AC_MSG_ERROR([Make step failed !]) AC_MSG_NOTICE([Built successfully.]) make install || AC_MSG_ERROR([Make step failed !]) cd - librsb_conf="${LIBRSB_PREFIX}"/bin/librsb-config test -f ${librsb_conf} || AC_MSG_ERROR([Temporary librsb installation config file ${librsb_conf} not executable ? Something went wrong with the install ?!]) AC_MSG_NOTICE([Temporary librsb installation in ${LIBRSB_PREFIX} done.]) AC_MSG_NOTICE([Forcing static linking due to temporary librsb.]) librsb_conf_static='yes' else AC_MSG_NOTICE([No librsb tarball provided: following the default procedure.]) true; fi # END tarball-based on-the-fly install of librsb if test x"$librsb_conf" = x"no" ; then AC_ARG_WITH(librsb-conf, [ --with-librsb-conf=... Path to the librsb-config program (or its directory) which will be used to recover SPARSERSB_CXXFLAGS and SPARSERSB_LDFLAGS (unless specified explicitly).], [ librsb_conf=$withval; ], [ librsb_conf=no ]) if test x"$librsb_conf" != x"no" ; then if test -d "$librsb_conf" -a -x "$librsb_conf/librsb-config"; then AC_MSG_NOTICE([Considering user provided ${librsb_conf} config dir.]) librsb_conf="$librsb_conf/librsb-config"; fi if test '!' -x "$librsb_conf" ; then AC_MSG_NOTICE([Taking absolute path to ${librsb_conf}.]) librsb_conf=`which "$librsb_conf"` fi if test -x "$librsb_conf" ; then true dnl AC_MSG_NOTICE([Using user provided ${librsb_conf} config file.]) else AC_MSG_ERROR([Executable config file not found with user-provided ${librsb_conf} path!]) fi fi else AC_MSG_NOTICE([Using ${librsb_conf} config file from the local librsb installation.]) fi if test x"$librsb_conf" != x"no" ; then AC_MSG_NOTICE([Using user provided $librsb_conf script for librsb.]) else dnl AC_MSG_NOTICE([Probing for a librsb-config script...]) AC_CHECK_PROG([HAVE_LIBRSB_CONFIG], [librsb-config], [yes], [no]) if [test "x$HAVE_LIBRSB_CONFIG" != x"no"]; then librsb_conf=librsb-config fi fi if [test x"$SPARSERSB_CXXFLAGS" != "x" ]; then AC_MSG_NOTICE([Using user set SPARSERSB_CXXFLAGS...]) else if [test x"$librsb_conf" != x"no"]; then AC_MSG_NOTICE([Setting SPARSERSB_CXXFLAGS from $librsb_conf --I_opts...]) SPARSERSB_CXXFLAGS="`$librsb_conf --I_opts`" fi fi OCTAVE_CLI="$OCTAVE --no-gui --no-window-system"; SPARSERSB_USE_64BIT_IDX=`$OCTAVE_CLI --no-line-editing -qf --eval 'printf ("%i", sizemax() > intmax ("int32"))'` if [test x"$SPARSERSB_USE_64BIT_IDX" = x"1" ]; then AC_MSG_NOTICE([Adding -D RSBOI_DETECTED_LONG_IDX to SPARSERSB_CXXFLAGS ...]) SPARSERSB_CXXFLAGS="$SPARSERSB_CXXFLAGS -D RSBOI_DETECTED_LONG_IDX=1" fi if [test x"$SPARSERSB_LDFLAGS" != "x" ]; then AC_MSG_NOTICE([Using user set SPARSERSB_LDFLAGS...]) else if [test x"$librsb_conf" != x"no"]; then if [test x"$librsb_conf_static" = x"no"]; then AC_MSG_NOTICE([Setting SPARSERSB_LDFLAGS from --L_opts --libs]) SPARSERSB_LDFLAGS="`$librsb_conf --L_opts --libs`" else AC_MSG_NOTICE([Setting SPARSERSB_LDFLAGS from --static --libs --extra_libs]) SPARSERSB_LDFLAGS="`$librsb_conf --static --libs --extra_libs`" fi fi fi if [test x"$SPARSERSB_CXXFLAGS" = "x" ]; then AC_CHECK_HEADERS([rsb.h], [AC_SEARCH_LIBS([rsb_lib_init], [rsb], [SPARSERSB_CXXFLAGS=" "], [])], [] ) fi if [test x"$SPARSERSB_LDFLAGS" = "x" ]; then AC_CHECK_HEADERS([rsb.h], [AC_SEARCH_LIBS([rsb_lib_init], [rsb], [SPARSERSB_LDFLAGS="-lrsb"], [])], [] ) fi if [test x"$SPARSERSB_CXXFLAGS" = "x" ]; then AC_MSG_ERROR([$PACKAGE_NAME SPARSERSB_CXXFLAGS (librsb not detected)!]) fi if [test x"$SPARSERSB_LDFLAGS" = "x" ]; then AC_MSG_ERROR([$PACKAGE_NAME requires SPARSERSB_LDFLAGS (librsb not detected)!]) fi have_rsb=yes AC_MSG_NOTICE([SPARSERSB_CXXFLAGS is $SPARSERSB_CXXFLAGS]) AC_MSG_NOTICE([SPARSERSB_LDFLAGS is $SPARSERSB_LDFLAGS]) # TODO: alternative: build librsb with SPARSERSB_LIBRSB_TARBALL # TODO: alternative: --with-librsb=tarball will skip all checks and use that tarball if [ test "$have_rsb" != "yes" ]; then AC_MSG_ERROR([$PACKAGE_NAME requires librsb library]) fi # check for octave functions save_CXX="$CXX" save_CXXFLAGS="$CXXFLAGS" CXX=`${MKOCTFILE} -p CXX` CXXFLAGS="$CXXFLAGS -I`$MKOCTFILE -p OCTINCLUDEDIR`" # need to use interpreter->get_load_path in dev version of octave, # prior to that methods of load_path were static AC_CACHE_CHECK( [for octave_value function iscomplex], [octave_value_cv_iscomplex], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([ #include #include ], [ octave_value().iscomplex(); ])], [octave_value_cv_iscomplex=yes], [octave_value_cv_iscomplex=no]) ]) if test "$octave_value_cv_iscomplex" = "yes" ; then HAVE_OCTAVE_VALUE_ISCOMPLEX=-DHAVE_OCTAVE_VALUE_ISCOMPLEX else HAVE_OCTAVE_VALUE_ISCOMPLEX= fi AC_SUBST(HAVE_OCTAVE_VALUE_ISCOMPLEX) CC=$save_CXX CXXFLAGS=$save_CXXFLAGS AC_SUBST(OCTAVE) AC_SUBST(TARGETS) AC_SUBST(SPARSERSB_CXXFLAGS) AC_SUBST(SPARSERSB_CXX11, ["-std=gnu++11"]) AC_SUBST(SPARSERSB_LDFLAGS) AC_CONFIG_FILES([Makeconf]) AC_OUTPUT AC_MSG_NOTICE([ $PACKAGE_NAME is configured with: SPARSERSB_LDFLAGS: $SPARSERSB_LDFLAGS SPARSERSB_CXXFLAGS: $SPARSERSB_CXXFLAGS SPARSERSB_CXX11: $SPARSERSB_CXX11 OCTAVE: $OCTAVE MKOCTFILE: $MKOCTFILE dnl LIBS: $LIBS dnl CXXFLAGS: $CXXFLAGS $DEFS dnl TARGETS: $TARGETS You can build it with 'make' and after on, test with 'make tests'. ]) sparsersb-1.0.9/src/ext/gettok.m0000644000000000000000000000306514122214045014714 0ustar 00000000000000# # Copyright (C) 2011-2020 Michele Martone # # 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 . # ## Original version was from the NIST "Matrix Market" service ## https://math.nist.gov/MatrixMarket/mmio/matlab/mmiomatlab.html ## and distributed as free software in the public domain. function [word, remainder] = gettok(string) % % function [word, remainder] = gettok(string) % % Retrieves the first blank separated token from the string. % si = findstr(string,' '); lstring=length(string); lsi=length(si); if ( lsi == 0 ) word=string; remainder=''; return end firstb=si(1); if ( firstb > 1 ) word=string(1:firstb-1); remainder=string(firstb+1:lstring); return; end tmp=1; while ( tmp < lsi ) if ( si(tmp+1) == si(tmp)+1 ) tmp=tmp+1; else break; end end if ( tmp == lstring ) word=-1; remainder=string; return; end word=string(si(tmp)+1:si(tmp+1)-1); remainder=string(si(tmp+1)+1:lstring); sparsersb-1.0.9/src/ext/mminfo.m0000644000000000000000000001011414122214045014675 0ustar 00000000000000# # Copyright (C) 2011-2020 Michele Martone # # 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 . # ## Original version was from the NIST "Matrix Market" service ## https://math.nist.gov/MatrixMarket/mmio/matlab/mmiomatlab.html ## and distributed as free software in the public domain. function [rows, cols, entries, rep, field, symm] = mminfo(filename) % % function [rows, cols, entries, rep, field, symmetry] = mminfo(filename) % % Reads the contents of the Matrix Market file 'filename' % and extracts size and storage information. % % In the case of coordinate matrices, entries refers to the % number of coordinate entries stored in the file. The number % of non-zero entries in the final matrix cannot be determined % until the data is read (and symmetrized, if necessary). % % In the case of array matrices, entries is the product % rows*cols, regardless of whether symmetry was used to % store the matrix efficiently. % % mmfile = fopen(filename,'r'); if ( mmfile == -1 ) disp(filename); error('File not found'); end; header = fgets(mmfile); if (header == -1 ) error('Empty file.') end % NOTE: If using a version of Matlab for which strtok is not % defined, substitute 'gettok' for 'strtok' in the % following lines, and download gettok.m from the % Matrix Market site. [head0,header] = strtok(header); % see note above [head1,header] = strtok(header); [rep,header] = strtok(header); [field,header] = strtok(header); [symm,header] = strtok(header); head1 = lower(head1); rep = lower(rep); field = lower(field); symm = lower(symm); if ( length(symm) == 0 ) disp('Not enough words in header line.') disp('Recognized format: ') disp('%%MatrixMarket matrix representation field symmetry') error('Check header line.') end if ( ~ strcmp(head0,'%%MatrixMarket') ) error('Not a valid MatrixMarket header.') end if ( ~ strcmp(head1,'matrix') ) disp(['This seems to be a MatrixMarket ',head1,' file.']); disp('This function only knows how to read MatrixMarket matrix files.'); disp(' '); error(' '); end % Read through comments, ignoring them commentline = fgets(mmfile); while length(commentline) > 0 & commentline(1) == '%', commentline = fgets(mmfile); end % Read size information, then branch according to % sparse or dense format if ( strcmp(rep,'coordinate')) % read matrix given in sparse % coordinate matrix format [sizeinfo,count] = sscanf(commentline,'%d%d%d'); while ( count == 0 ) commentline = fgets(mmfile); if (commentline == -1 ) error('End-of-file reached before size information was found.') end [sizeinfo,count] = sscanf(commentline,'%d%d%d'); if ( count > 0 & count ~= 3 ) error('Invalid size specification line.') end end rows = sizeinfo(1); cols = sizeinfo(2); entries = sizeinfo(3); elseif ( strcmp(rep,'array') ) % read matrix given in dense % array (column major) format [sizeinfo,count] = sscanf(commentline,'%d%d'); while ( count == 0 ) commentline = fgets(mmfile); if (commentline == -1 ) error('End-of-file reached before size information was found.') end [sizeinfo,count] = sscanf(commentline,'%d%d'); if ( count > 0 & count ~= 2 ) error('Invalid size specification line.') end end rows = sizeinfo(1); cols = sizeinfo(2); entries = rows*cols; end fclose(mmfile); % Done. sparsersb-1.0.9/src/ext/mmread.m0000644000000000000000000002164314122214045014666 0ustar 00000000000000# # Copyright (C) 2011-2020 Michele Martone # # 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 . # ## Original version was from the NIST "Matrix Market" service ## https://math.nist.gov/MatrixMarket/mmio/matlab/mmiomatlab.html ## and distributed as free software in the public domain. # 20070301 # Slightly modified by Michele Martone for handling complex dense arrays with parenthesis,too # But there still a bug (original!): the first line MUST be space terminated.. function [A,rows,cols,entries,rep,field,symm] = mmread(filename) % % function [A] = mmread(filename) % % function [A,rows,cols,entries,rep,field,symm] = mmread(filename) % % Reads the contents of the Matrix Market file 'filename' % into the matrix 'A'. 'A' will be either sparse or full, % depending on the Matrix Market format indicated by % 'coordinate' (coordinate sparse storage), or % 'array' (dense array storage). The data will be duplicated % as appropriate if symmetry is indicated in the header. % % Optionally, size information about the matrix can be % obtained by using the return values rows, cols, and % entries, where entries is the number of nonzero entries % in the final matrix. Type information can also be retrieved % using the optional return values rep (representation), field, % and symm (symmetry). % mmfile = fopen(filename,'rb');#'b' added by MM if ( mmfile == -1 ) disp(filename); error('File not found'); end; header = fgets(mmfile); if (header == -1 ) error('Empty file.') end % NOTE: If using a version of Matlab for which strtok is not % defined, substitute 'gettok' for 'strtok' in the % following lines, and download gettok.m from the % Matrix Market site. [head0,header] = strtok(header); % see note above [head1,header] = strtok(header); [rep,header] = strtok(header); [field,header] = strtok(header); [symm,header] = strtok(header); head1 = lower(head1); rep = lower(rep); field = lower(field); symm = lower(symm); if ( length(symm) == 0 ) disp(['Not enough words in header line of file ',filename]) disp('Recognized format: ') disp('%%MatrixMarket matrix representation field symmetry') error('Check header line.') end if ( ~ strcmp(head0,'%%MatrixMarket') ) error('Not a valid MatrixMarket header.') end if ( ~ strcmp(head1,'matrix') ) disp(['This seems to be a MatrixMarket ',head1,' file.']); disp('This function only knows how to read MatrixMarket matrix files.'); disp(' '); error(' '); end % Read through comments, ignoring them commentline = fgets(mmfile); while length(commentline) > 0 & commentline(1) == '%', commentline = fgets(mmfile); end % Read size information, then branch according to % sparse or dense format if ( strcmp(rep,'coordinate')) % read matrix given in sparse % coordinate matrix format [sizeinfo,count] = sscanf(commentline,'%d%d%d'); while ( count == 0 ) commentline = fgets(mmfile); if (commentline == -1 ) error('End-of-file reached before size information was found.') end [sizeinfo,count] = sscanf(commentline,'%d%d%d'); if ( count > 0 & count ~= 3 ) error('Invalid size specification line.') end end rows = sizeinfo(1); cols = sizeinfo(2); entries = sizeinfo(3); if ( strcmp(field,'real') ) % real valued entries: [T,count] = fscanf(mmfile,'%f',3); T = [T; fscanf(mmfile,'%f')]; if ( size(T) ~= 3*entries ) message = ... str2mat('Data file does not contain expected amount of data.',... 'Check that number of data lines matches nonzero count.'); disp(message); error('Invalid data.'); end T = reshape(T,3,entries)'; A = sparse(T(:,1), T(:,2), T(:,3), rows , cols); elseif ( strcmp(field,'complex')) % complex valued entries: T = fscanf(mmfile,'%f',4); T = [T; fscanf(mmfile,'%f')]; if ( size(T) ~= 4*entries ) message = ... str2mat('Data file does not contain expected amount of data.',... 'Check that number of data lines matches nonzero count.'); disp(message); error('Invalid data.'); end T = reshape(T,4,entries)'; A = sparse(T(:,1), T(:,2), T(:,3) + T(:,4)*sqrt(-1), rows , cols); elseif ( strcmp(field,'pattern')) % pattern matrix (no values given): T = fscanf(mmfile,'%f',2); T = [T; fscanf(mmfile,'%f')]; if ( size(T) ~= 2*entries ) message = ... str2mat('Data file does not contain expected amount of data.',... 'Check that number of data lines matches nonzero count.'); disp(message); error('Invalid data.'); end T = reshape(T,2,entries)'; A = sparse(T(:,1), T(:,2), ones(entries,1) , rows , cols); end elseif ( strcmp(rep,'array') ) % read matrix given in dense % array (column major) format [sizeinfo,count] = sscanf(commentline,'%d%d'); while ( count == 0 ) commentline = fgets(mmfile); if (commentline == -1 ) error('End-of-file reached before size information was found.') end [sizeinfo,count] = sscanf(commentline,'%d%d'); if ( count > 0 & count ~= 2 ) error('Invalid size specification line.') end end rows = sizeinfo(1); cols = sizeinfo(2); entries = rows*cols; if ( strcmp(field,'real') ) % real valued entries: A = fscanf(mmfile,'%f',1); A = [A; fscanf(mmfile,'%f')]; if ( strcmp(symm,'symmetric') | strcmp(symm,'hermitian') | strcmp(symm,'skew-symmetric') ) for j=1:cols-1, currenti = j*rows; A = [A(1:currenti); zeros(j,1);A(currenti+1:length(A))]; end elseif ( ~ strcmp(symm,'general') ) disp('Unrecognized symmetry') disp(symm) disp('Recognized choices:') disp(' symmetric') disp(' hermitian') disp(' skew-symmetric') disp(' general') error('Check symmetry specification in header.'); end A = reshape(A,rows,cols); elseif ( strcmp(field,'complex')) % complx valued entries: %tmpr = fscanf(mmfile,'%f',1); %tmpi = fscanf(mmfile,'%f',1); % no braindead code please.. [tmpr,_c] = fscanf(mmfile,'%f',1); [tmpi,_c] = fscanf(mmfile,'%f',1); if(_c!=1) fscanf(mmfile,'('); [tmpr,_c] = fscanf(mmfile,'%f' ,1); fscanf(mmfile,','); [tmpi,_c] = fscanf(mmfile,'%f',1); fscanf(mmfile,')'); endif A=reshape(zeros(entries,1).+0*i,entries,1); % A = tmpr+tmpi*i; A(1) = tmpr+tmpi*i; % for j=1:entries-1 for j=2:entries % now the algorithm is slightly different! [tmpr,_c] = fscanf(mmfile,'%f',1); [tmpi,_c] = fscanf(mmfile,'%f',1); if(_c!=1) fscanf(mmfile,'('); [tmpr,_c] = fscanf(mmfile,'%f' ,1); fscanf(mmfile,','); [tmpi,_c] = fscanf(mmfile,'%f',1); fscanf(mmfile,')'); endif % A = [A; tmpr + tmpi*i] % <- braindead code! A(j)=tmpr+tmpi*i; % printf("%f,%f",A(j)); end if ( strcmp(symm,'symmetric') | strcmp(symm,'hermitian') | strcmp(symm,'skew-symmetric') ) for j=1:cols-1, currenti = j*rows; A = [A(1:currenti); zeros(j,1);A(currenti+1:length(A))]; end elseif ( strcmp(symm,'general') ) %elseif ( ~ strcmp(symm,'general') ) disp('Unrecognized symmetry') disp(symm) disp('Recognized choices:') disp(' symmetric') disp(' hermitian') disp(' skew-symmetric') disp(' general') error('Check symmetry specification in header.'); end A = reshape(A,rows,cols); elseif ( strcmp(field,'pattern')) % pattern (makes no sense for dense) disp('Matrix type:',field) error('Pattern matrix type invalid for array storage format.'); else % Unknown matrix type disp('Matrix type:',field) error('Invalid matrix type specification. Check header against MM documentation.'); end end % % If symmetric, skew-symmetric or Hermitian, duplicate lower % triangular part and modify entries as appropriate: % if ( strcmp(symm,'symmetric') ) A = A + A.' - diag(diag(A)); entries = nnz(A); elseif ( strcmp(symm,'hermitian') ) A = A + A' - diag(diag(A)); entries = nnz(A); elseif ( strcmp(symm,'skew-symmetric') ) A = A - A'; entries = nnz(A); end fclose(mmfile); % Done. sparsersb-1.0.9/src/ext/mmreadm.m0000644000000000000000000002174714122214045015050 0ustar 00000000000000# # Copyright (C) 2011-2020 Michele Martone # # 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 . # ## Original version was from the NIST "Matrix Market" service ## https://math.nist.gov/MatrixMarket/mmio/matlab/mmiomatlab.html ## and distributed as free software in the public domain. % 20111022 % Slightly modified by Michele Martone for Matlab at IPP MPG. % 20070301 % Slightly modified by Michele Martone for handling complex dense arrays with parenthesis,too % But there still a bug (original!): the first line MUST be space terminated.. function [A,rows,cols,entries,rep,field,symm] = mmreadm(filename) % % function [A] = mmreadm(filename) % % function [A,rows,cols,entries,rep,field,symm] = mmreadm(filename) % % Reads the contents of the Matrix Market file 'filename' % into the matrix 'A'. 'A' will be either sparse or full, % depending on the Matrix Market format indicated by % 'coordinate' (coordinate sparse storage), or % 'array' (dense array storage). The data will be duplicated % as appropriate if symmetry is indicated in the header. % % Optionally, size information about the matrix can be % obtained by using the return values rows, cols, and % entries, where entries is the number of nonzero entries % in the final matrix. Type information can also be retrieved % using the optional return values rep (representation), field, % and symm (symmetry). % mmfile = fopen(filename,'rb');%'b' added by MM if ( mmfile == -1 ) disp(filename); error('File not found'); end; header = fgets(mmfile); if (header == -1 ) error('Empty file.') end % NOTE: If using a version of Matlab for which strtok is not % defined, substitute 'gettok' for 'strtok' in the % following lines, and download gettok.m from the % Matrix Market site. [head0,header] = gettok(header); % see note above [head1,header] = gettok(header); [rep,header] = gettok(header); [field,header] = gettok(header); [symm,header] = gettok(header); head1 = lower(head1); rep = lower(rep); field = lower(field); symm = lower(symm); if ( length(symm) == 0 ) disp(['Not enough words in header line of file ',filename]) disp('Recognized format: ') disp('%%MatrixMarket matrix representation field symmetry') error('Check header line.') end if ( ~ strcmp(head0,'%%MatrixMarket') ) error('Not a valid MatrixMarket header.') end if ( ~ strcmp(head1,'matrix') ) disp(['This seems to be a MatrixMarket ',head1,' file.']); disp('This function only knows how to read MatrixMarket matrix files.'); disp(' '); error(' '); end % Read through comments, ignoring them commentline = fgets(mmfile); while length(commentline) > 0 & commentline(1) == '%', commentline = fgets(mmfile); end % Read size information, then branch according to % sparse or dense format if ( strcmp(rep,'coordinate')) % read matrix given in sparse % coordinate matrix format [sizeinfo,count] = sscanf(commentline,'%d%d%d'); while ( count == 0 ) commentline = fgets(mmfile); if (commentline == -1 ) error('End-of-file reached before size information was found.') end [sizeinfo,count] = sscanf(commentline,'%d%d%d'); if ( count > 0 & count ~= 3 ) error('Invalid size specification line.') end end rows = sizeinfo(1); cols = sizeinfo(2); entries = sizeinfo(3); if ( strcmp(field,'real') ) % real valued entries: [T,count] = fscanf(mmfile,'%f',3); T = [T; fscanf(mmfile,'%f')]; if ( size(T) ~= 3*entries ) message = ... str2mat('Data file does not contain expected amount of data.',... 'Check that number of data lines matches nonzero count.'); disp(message); error('Invalid data.'); end T = reshape(T,3,entries)'; A = sparse(T(:,1), T(:,2), T(:,3), rows , cols); elseif ( strcmp(field,'complex')) % complex valued entries: T = fscanf(mmfile,'%f',4); T = [T; fscanf(mmfile,'%f')]; if ( size(T) ~= 4*entries ) message = ... str2mat('Data file does not contain expected amount of data.',... 'Check that number of data lines matches nonzero count.'); disp(message); error('Invalid data.'); end T = reshape(T,4,entries)'; A = sparse(T(:,1), T(:,2), T(:,3) + T(:,4)*sqrt(-1), rows , cols); elseif ( strcmp(field,'pattern')) % pattern matrix (no values given): T = fscanf(mmfile,'%f',2); T = [T; fscanf(mmfile,'%f')]; if ( size(T) ~= 2*entries ) message = ... str2mat('Data file does not contain expected amount of data.',... 'Check that number of data lines matches nonzero count.'); disp(message); error('Invalid data.'); end T = reshape(T,2,entries)'; A = sparse(T(:,1), T(:,2), ones(entries,1) , rows , cols); end elseif ( strcmp(rep,'array') ) % read matrix given in dense % array (column major) format [sizeinfo,count] = sscanf(commentline,'%d%d'); while ( count == 0 ) commentline = fgets(mmfile); if (commentline == -1 ) error('End-of-file reached before size information was found.') end [sizeinfo,count] = sscanf(commentline,'%d%d'); if ( count > 0 & count ~= 2 ) error('Invalid size specification line.') end end rows = sizeinfo(1); cols = sizeinfo(2); entries = rows*cols; if ( strcmp(field,'real') ) % real valued entries: A = fscanf(mmfile,'%f',1); A = [A; fscanf(mmfile,'%f')]; if ( strcmp(symm,'symmetric') | strcmp(symm,'hermitian') | strcmp(symm,'skew-symmetric') ) for j=1:cols-1, currenti = j*rows; A = [A(1:currenti); zeros(j,1);A(currenti+1:length(A))]; end elseif ( ~ strcmp(symm,'general') ) disp('Unrecognized symmetry') disp(symm) disp('Recognized choices:') disp(' symmetric') disp(' hermitian') disp(' skew-symmetric') disp(' general') error('Check symmetry specification in header.'); end A = reshape(A,rows,cols); elseif ( strcmp(field,'complex')) % complx valued entries: %tmpr = fscanf(mmfile,'%f',1); %tmpi = fscanf(mmfile,'%f',1); % no braindead code please.. [tmpr,c] = fscanf(mmfile,'%f',1); [tmpi,c] = fscanf(mmfile,'%f',1); if(ne(c,1)) fscanf(mmfile,'('); [tmpr,c] = fscanf(mmfile,'%f' ,1); fscanf(mmfile,','); [tmpi,c] = fscanf(mmfile,'%f',1); fscanf(mmfile,')'); end A=reshape(zeros(entries,1) +0*i,entries,1); % A = tmpr+tmpi*i; A(1) = tmpr+tmpi*i; % for j=1:entries-1 for j=2:entries % now the algorithm is slightly different! [tmpr,c] = fscanf(mmfile,'%f',1); [tmpi,c] = fscanf(mmfile,'%f',1); if(ne(c,1)) fscanf(mmfile,'('); [tmpr,c] = fscanf(mmfile,'%f' ,1); fscanf(mmfile,','); [tmpi,c] = fscanf(mmfile,'%f',1); fscanf(mmfile,')'); end % A = [A; tmpr + tmpi*i] % <- braindead code! A(j)=tmpr+tmpi*i; % printf("%f,%f",A(j)); end if ( strcmp(symm,'symmetric') | strcmp(symm,'hermitian') | strcmp(symm,'skew-symmetric') ) for j=1:cols-1, currenti = j*rows; A = [A(1:currenti); zeros(j,1);A(currenti+1:length(A))]; end elseif ( strcmp(symm,'general') ) %elseif ( ~ strcmp(symm,'general') ) disp('Unrecognized symmetry') disp(symm) disp('Recognized choices:') disp(' symmetric') disp(' hermitian') disp(' skew-symmetric') disp(' general') error('Check symmetry specification in header.'); end A = reshape(A,rows,cols); elseif ( strcmp(field,'pattern')) % pattern (makes no sense for dense) disp('Matrix type:',field) error('Pattern matrix type invalid for array storage format.'); else % Unknown matrix type disp('Matrix type:',field) error('Invalid matrix type specification. Check header against MM documentation.'); end end % % If symmetric, skew-symmetric or Hermitian, duplicate lower % triangular part and modify entries as appropriate: % if ( strcmp(symm,'symmetric') ) A = A + A.' - diag(diag(A)); entries = nnz(A); elseif ( strcmp(symm,'hermitian') ) A = A + A' - diag(diag(A)); entries = nnz(A); elseif ( strcmp(symm,'skew-symmetric') ) A = A - A'; entries = nnz(A); end fclose(mmfile); % Done. sparsersb-1.0.9/src/ext/mmwrite.m0000644000000000000000000001721714122214045015107 0ustar 00000000000000# # Copyright (C) 2011-2020 Michele Martone # # 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 . # ## Original version was from the NIST "Matrix Market" service ## https://math.nist.gov/MatrixMarket/mmio/matlab/mmiomatlab.html ## and distributed as free software in the public domain. function [ err ] = mmwrite(filename,A,comment,field,precision) % % Function: mmwrite(filename,A,comment,field,precision) % % Writes the sparse or dense matrix A to a Matrix Market (MM) % formatted file. % % Required arguments: % % filename - destination file % % A - sparse or full matrix % % Optional arguments: % % comment - matrix of comments to prepend to % the MM file. To build a comment matrix, % use str2mat. For example: % % comment = str2mat(' Comment 1' ,... % ' Comment 2',... % ' and so on.',... % ' to attach a date:',... % [' ',date]); % If ommitted, a single line date stamp comment % will be included. % % field - 'real' % 'complex' % 'integer' % 'pattern' % If ommitted, data will determine type. % % precision - number of digits to display for real % or complex values % If ommitted, full working precision is used. % if ( nargin == 5) precision = 16; elseif ( nargin == 4) precision = 16; elseif ( nargin == 3) mattype = 'real'; % placeholder, will check after FIND-ing A precision = 16; elseif ( nargin == 2) comment = ''; % Check whether there is an imaginary part: mattype = 'real'; % placeholder, will check after FIND-ing A precision = 16; end mmfile = fopen([filename],'wb');#'b' added by MM if ( mmfile == -1 ) error('Cannot open file for output'); end; [M,N] = size(A); %%%%%%%%%%%%% This part for sparse matrices %%%%%%%%%%%%%%%% if ( issparse(A) ) [I,J,V] = find(A); if ( sum(abs(imag(nonzeros(V)))) > 0 ) Vreal = 0; else Vreal = 1; end if ( ~ strcmp(mattype,'pattern') & Vreal ) mattype = 'real'; elseif ( ~ strcmp(mattype,'pattern') ) mattype = 'complex'; end % % Determine symmetry: % if ( M ~= N ) symm = 'general'; issymm = 0; NZ = length(V); else issymm = 1; NZ = length(V); for i=1:NZ if ( A(J(i),I(i)) ~= V(i) ) issymm = 0; break; end end if ( issymm ) symm = 'symmetric'; ATEMP = tril(A); [I,J,V] = find(ATEMP); NZ = nnz(ATEMP); else isskew = 1; for i=1:NZ if ( A(J(i),I(i)) ~= - V(i) ) isskew = 0; break; end end if ( isskew ) symm = 'skew-symmetric'; ATEMP = tril(A); [I,J,V] = find(ATEMP); NZ = nnz(ATEMP); elseif ( strcmp(mattype,'complex') ) isherm = 1; for i=1:NZ if ( A(J(i),I(i)) ~= conj(V(i)) ) isherm = 0; break; end end if ( isherm ) symm = 'hermitian'; ATEMP = tril(A); [I,J,V] = find(ATEMP); NZ = nnz(ATEMP); else symm = 'general'; NZ = nnz(A); end else symm = 'general'; NZ = nnz(A); end end end % Sparse coordinate format: rep = 'coordinate'; fprintf(mmfile,'%%%%MatrixMarket matrix %s %s %s\n',rep,mattype,symm); [MC,NC] = size(comment); if ( MC == 0 ) fprintf(mmfile,'%% Generated %s\n',[date]); else for i=1:MC, fprintf(mmfile,'%%%s\n',comment(i,:)); end end fprintf(mmfile,'%d %d %d\n',M,N,NZ); cplxformat = sprintf('%%d %%d %% .%dg %% .%dg\n',precision,precision); realformat = sprintf('%%d %%d %% .%dg\n',precision); if ( strcmp(mattype,'real') ) for i=1:NZ fprintf(mmfile,realformat,I(i),J(i),V(i)); end; elseif ( strcmp(mattype,'complex') ) for i=1:NZ fprintf(mmfile,cplxformat,I(i),J(i),real(V(i)),imag(V(i))); end; elseif ( strcmp(mattype,'pattern') ) for i=1:NZ fprintf(mmfile,'%d %d\n',I(i),J(i)); end; else err = -1; disp('Unsupported mattype:') mattype end; %%%%%%%%%%%%% This part for dense matrices %%%%%%%%%%%%%%%% else if ( sum(abs(imag(nonzeros(A)))) > 0 ) Areal = 0; else Areal = 1; end if ( ~strcmp(mattype,'pattern') & Areal ) mattype = 'real'; elseif ( ~strcmp(mattype,'pattern') ) mattype = 'complex'; end % % Determine symmetry: % if ( M ~= N ) issymm = 0; symm = 'general'; else issymm = 1; for j=1:N for i=j+1:N if (A(i,j) ~= A(j,i) ) issymm = 0; break; end end if ( ~ issymm ) break; end end if ( issymm ) symm = 'symmetric'; else isskew = 1; for j=1:N for i=j+1:N if (A(i,j) ~= - A(j,i) ) isskew = 0; break; end end if ( ~ isskew ) break; end end if ( isskew ) symm = 'skew-symmetric'; elseif ( strcmp(mattype,'complex') ) isherm = 1; for j=1:N for i=j+1:N if (A(i,j) ~= conj(A(j,i)) ) isherm = 0; break; end end if ( ~ isherm ) break; end end if ( isherm ) symm = 'hermitian'; else symm = 'general'; end else symm = 'general'; end end end % Dense array format: rep = 'array'; [MC,NC] = size(comment); fprintf(mmfile,'%%%%MatrixMarket matrix %s %s %s\n',rep,mattype,symm); for i=1:MC, fprintf(mmfile,'%%%s\n',comment(i,:)); end; fprintf(mmfile,'%d %d\n',M,N); cplxformat = sprintf('%% .%dg %% .%dg\n', precision,precision); realformat = sprintf('%% .%dg\n', precision); if ( ~ strcmp(symm,'general') ) rowloop = 'j'; else rowloop = '1'; end if ( strcmp(mattype,'real') ) for j=1:N for i=eval(rowloop):M fprintf(mmfile,realformat,A(i,j)); end end elseif ( strcmp(mattype,'complex') ) for j=1:N for i=eval(rowloop):M fprintf(mmfile,cplxformat,real(A(i,j)),imag(A(i,j))); end end elseif ( strcmp(mattype,'pattern') ) err = -2 disp('Pattern type inconsistant with dense matrix') else err = -2 disp('Unknown matrix type:') mattype end end fclose(mmfile); sparsersb-1.0.9/src/matlabbench.sh0000755000000000000000000000030114122214045015226 0ustar 00000000000000#!/bin/bash if test $# != 1 ; then echo "Please supply a single Matrix Market file name at the command line." ; exit; fi matlab -nojvm -nodisplay -nodesktop -nosplash -r "matlabbench('"$1"')" sparsersb-1.0.9/src/sparsersb.cc0000644000000000000000000066441414122214045014767 0ustar 00000000000000/* Copyright (C) 2011-2021 Michele Martone 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 . */ /* * This obsolete wishlist. Patches are welcome!: * adapt to when octave_idx_type is 64 bit long * rsb_file_vec_save (1.1) * all *.m files shall go to inst/ * switch to using bootstrap.sh (instead autogen.sh) and configure.ac with environment variables, so it can be called from pkg install sparsersb-1.0.4.tar.gz * produce ../doc/sparsersb.txi; can use get_help_text * put to ./devel/ what is not to be distributed * make or configure should fail on missing library (actually it does not) * spfind in order to update easily and quickly nonzeroes * need A(IA,JA,VA)=nVA * shall add "load"; implicit filename based is confusing * shall rename "load"/"save" to "loadMatrixMarket"/... or something explicit * save/load capability (in own, rsb format) * should not rely on string_value().c_str() --- stack corruption danger! * ("get","RSB_IO_WANT_...") is not yet available * (.) is incomplete. it is needed by trace() * (:,:) , (:,p): test with octave's bicg, bicgstab, cgs, ... * hints about how to influence caching blocking policy * compound_binary_op * for thorough testing, see Octave's test/build_sparse_tests.sh * sparsersb(rsbmat,"benchmark") * sparsersb(rsbmat,"test") * minimize data copies * subsref, dotref, subsasgn are incomplete: need error messages there * in full_value(), bool arg is ignored * symmetry support is incomplete (scarcely defined) * document semantics of update and access operators * define more operators (e.g.: scaling) for 'complex' * create a single error macro for constructors * often missing array lenghts/type checks * may define as map (see is_map) so that "a.type = ..." can work * is_struct, find_nonzero_elem_idx are undefined * are octave_triangular_conv, default_numeric_conversion_function ok ? * error reporting is insufficient * update to symmetric be forbidden or rather trigger a conversion ? * after file read, return various structural info * norm computation * reformat code for readability * warnings about incomplete complex implementation may be overzealous. * need matrix exponentiation through conversion to octave format. * Note: although librsb has been optimized for performance, sparsersb is not. * Note: there are dangerous casts to rsb_coo_idx_t in subsasgn: for 64-bit octave_idx_type. * adopt a higher C++ level when possible * Developer notes: http://www.gnu.org/software/octave/doc/interpreter/index.html http://www.gnu.org/software/octave/doc/interpreter/Oct_002dFiles.html#Oct_002dFiles http://octave.sourceforge.net/developers.html */ #define RSBOI_WANT_PRINT_PCT_OCTAVE_STYLE 1 #include #define RSBOI_USE_PATCH_OCT44 (OCTAVE_MAJOR_VERSION>=5) || ( (OCTAVE_MAJOR_VERSION==4) && (OCTAVE_MINOR_VERSION>=4)) #if RSBOI_USE_PATCH_OCT44 #include #include #include #endif /* RSBOI_USE_PATCH_OCT44 */ #include #include #include /* RSBOI_WANT_SPMTX_SUBSREF || RSBOI_WANT_SPMTX_SUBSASGN */ #include #include #include #include #if RSBOI_WANT_PRINT_PCT_OCTAVE_STYLE #include // std::setprecision #endif #include #if RSBOI_USE_PATCH_OCT44 /* transitional macros, new style */ #define RSBOI_TRY_BLK try #define RSBOI_CATCH_BLK catch (octave::execution_exception& e) { goto err; } #define RSBOI_IF_ERR(STMT) #define RSBOI_IF_NERR(STMT) STMT #define RSBOI_IF_NERR_STATE() /* transitional macros, old style */ #else /* RSBOI_USE_PATCH_OCT44 */ #define RSBOI_IF_ERR(STMT) if ( error_state) STMT #define RSBOI_IF_NERR(STMT) if (! error_state) STMT #define RSBOI_IF_NERR_STATE() if (! error_state) #endif /* RSBOI_USE_PATCH_OCT44 */ //#define RSBOI_VERBOSE_CONFIG 1 /* poor man's trace facility */ #ifdef RSBOI_VERBOSE_CONFIG /* poor man's trace facility */ #if (RSBOI_VERBOSE_CONFIG>0) #define RSBOI_VERBOSE RSBOI_VERBOSE_CONFIG #endif #endif #define RSBOI_USE_PATCH_38143 ( defined(OCTAVE_MAJOR_VERSION) && (OCTAVE_MAJOR_VERSION>=4) ) /* See http://savannah.gnu.org/bugs/?48335#comment5 */ #if 0 #define RSBOI_WARN( MSG ) \ octave_stdout << "Warning in "<<__func__<<"(), in file "<<__FILE__<<" at line "<<__LINE__<<":\n" << MSG; #define RSBOI_FIXME( MSG ) RSBOI_WARN( MSG )/* new */ #else #define RSBOI_WARN( MSG ) #endif #define RSBOI_TODO( MSG ) RSBOI_WARN( MSG )/* new */ #define RSBOI_FIXME( MSG ) RSBOI_WARN( "FIXME: "MSG )/* new */ #define RSBOI_PRINTF( ... ) printf( __VA_ARGS__ ) #if RSBOI_VERBOSE //printf("In file %20s (in %s) at line %10d:\n",__FILE__,__func__,__LINE__), #define RSBOI_DEBUG_NOTICE( ... ) \ printf("In %s(), in file %s at line %10d:\n",__func__,__FILE__,__LINE__), \ printf( __VA_ARGS__ ) #if 0 #define RSBOI_ERROR( ... ) \ printf("In %s(), in file %s at line %10d:\n",__func__,__FILE__,__LINE__), \ printf( __VA_ARGS__ ) #else #define RSBOI_ERROR( MSG ) \ octave_stdout << "In "<<__func__<<"(), in file "<<__FILE__<<" at line "<<__LINE__<<":\n"<=201103L) ) #if defined(RSBOI_USE_CXX11) #define RSBOI_NULL nullptr #else /* RSBOI_USE_CXX11 */ #define RSBOI_NULL NULL #endif /* RSBOI_USE_CXX11 */ #define RSBOI_INFOBUF 256 #define RSBOI_WANT_SYMMETRY 1 #define RSBOI_WANT_PRINT_DETAIL 0 #define RSBOI_WANT_PRINT_COMPLEX_OR_REAL 0 #define RSBOI_WANT_SUBSREF 1 #define RSBOI_WANT_HEAVY_DEBUG 0 #define RSBOI_WANT_VECLOAD_INSTEAD_MTX 1 #define RSBOI_WANT_MTX_LOAD 1 #define RSBOI_WANT_MTX_SAVE 1 #define RSBOI_WANT_POW 1 #define RSBOI_WANT_QSI 1 /* query string interface */ #define RSBOI_WANT_RESHAPE 1 #define RSBOI_WANT_SPMTX_SUBSREF 0 /* not yet there: need to accumulate in sparse */ #define RSBOI_WANT_SPMTX_SUBSASGN 1 #define RSBOI_WANT_OS_1D_IDX_ACCESS 1 /* Octave-style 1D index access */ #define RSBOI_WANT_EXPAND_SYMM 1 /* Expand symmetry when converting to sparse */ //#define RSBOI_PERROR(E) rsb_perror(E) #define RSBOI_PERROR(E) if(RSBOI_SOME_ERROR(E)) rsboi_strerr(E) #ifdef RSB_TRANSPOSITION_INVALID #define RSBOI_INVALID_TRANS_CHAR RSB_TRANSPOSITION_INVALID /* since librsb-1.2.0.10 */ #else /* RSB_TRANSPOSITION_INVALID */ #define RSBOI_INVALID_TRANS_CHAR '?' #endif /* RSB_TRANSPOSITION_INVALID */ #ifdef RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX #include #include #endif #ifndef RSBOI_RSB_MATRIX_SOLVE #define RSBOI_RSB_MATRIX_SOLVE(V1,V2) RSBOI_0_ERROR(RSBOI_0_NOTERRMSG) /* any solution routine shall attached here */ #endif #if 1 extern "C" { rsb_err_t rsb_dump_postscript_from_mtx_t(const struct rsb_mtx_t *mtxAp, rsb_blk_idx_t br, rsb_blk_idx_t bc, int width, int height, rsb_bool_t all_nnz); } extern "C" { rsb_err_t rsb_dump_postscript_recursion_from_mtx_t(const struct rsb_mtx_t *mtxAp, rsb_blk_idx_t br, rsb_blk_idx_t bc, int width, int height, rsb_flags_t flags, rsb_bool_t want_blocks, rsb_bool_t z_dump , rsb_bool_t want_nonzeros ); } #endif #if RSBOI_WANT_HEAVY_DEBUG extern "C" { rsb_bool_t rsb_is_correctly_built_rcsr_matrix(const struct rsb_mtx_t *mtxAp); // forward declaration } #endif #if !RSBOI_WANT_OS_1D_IDX_ACCESS #if defined(RSB_LIBRSB_VER) && (RSB_LIBRSB_VER>=10100) extern "C" { #if (RSB_LIBRSB_VER<=10200) int rsb_do_get_nnz_element(struct rsb_mtx_t *,void*,void*,void*,int); #elif (RSB_LIBRSB_VER>=10300) int rsb__do_get_nnz_element(struct rsb_mtx_t *,void*,void*,void*,int); #define rsb_do_get_nnz_element rsb__do_get_nnz_element #endif } #endif #endif /* !RSBOI_WANT_OS_1D_IDX_ACCESS */ #if RSBOI_WANT_DOUBLE_COMPLEX #define RSBOI_BINOP_PREVAILING_TYPE(V1,V2) (((V1).iscomplex()||(V2).iscomplex())?RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX:RSB_NUMERICAL_TYPE_DOUBLE) #else #define RSBOI_BINOP_PREVAILING_TYPE(V1,V2) RSBOI_TYPECODE #endif #if defined(RSB_LIBRSB_VER) && (RSB_LIBRSB_VER>=10100) #define RSBOI_10100_DOCH \ "@deftypefnx {Loadable Function} " RSBOI_FNS " (@var{S},\"render\", @var{FILENAME}[, @var{rWidth}[, @var{rHeight}]])\n"\ "@deftypefnx {Loadable Function} {[@var{O} =]} " RSBOI_FNS " (@var{S},\"autotune\"[, @var{transA}[, @var{NRHS}[, @var{MAXR}[, @var{TMAX}[, @var{TN}[, @var{SF}]]]]]])\n"\ /* #define RSBOI_10100_DOC "If @var{S} is a " RSBOI_FNS " matrix and one of the \"render\",\"renderb\",\"renders\" keywords ... */ #define RSBOI_10100_DOC \ \ "If @var{S} is a @code{" RSBOI_FNS "} matrix and the @code{\"render\"} keyword is specified, and @var{FILENAME} is a string, @var{A} will be rendered as an Encapsulated Postscript file @var{FILENAME}. Optionally, width and height can be specified in @code{@var{rWidth}, @var{rHeight}}. Defaults are 512.\n"\ "\n"\ \ "If @var{S} is a @code{" RSBOI_FNS "} matrix and the @code{\"autotune\"} keyword is specified, autotuning of the matrix will take place, with SpMV and autotuning parameters. Parameters following the @code{\"autotune\"} string are optional. Parameter @var{transA} specifies whether to tune for untransposed (@code{\"N\"}) or transposed (@code{\"T\"}) or conjugated transposed (@code{\"C\"}); @var{NRHS} the number of right hand sides; @var{MAXR} the number of tuning rounds; @var{TMAX} the threads to use. If giving an output argument @var{O}, that will be assigned to the autotuned matrix, and the input one @var{A} will remain unchanged. See librsb documentation for @code{rsb_tune_spmm} to learn more.\n" #else #define RSBOI_10100_DOC "" #define RSBOI_10100_DOCH "" #endif #define RSBOI_VERSION 100009 /* e.g. 100009 means 1.0.9 */ #if defined(USE_64_BIT_IDX_T) || defined(OCTAVE_ENABLE_64) || defined(RSBOI_DETECTED_LONG_IDX) /* 4.1.0+ / 4.0.3 / any */ #define RSBOI_O64_R32 1 #else /* USE_64_BIT_IDX_T */ #define RSBOI_O64_R32 0 #endif /* USE_64_BIT_IDX_T */ #define RSBOI_SIZEMAX RSB_MAX_MATRIX_DIM /* Upper limit to librsb matrix dimension. */ static rsb_err_t rsboi_idxv_overflow( const idx_vector & IM, const idx_vector & JM) { rsb_err_t errval = RSB_ERR_NO_ERROR; if( IM.extent(0) > RSBOI_SIZEMAX || JM.extent(0) > RSBOI_SIZEMAX ) errval = RSB_ERR_LIMITS; return errval; } #if RSBOI_O64_R32 static rsb_err_t rsboi_idx_overflow( rsb_err_t *errvalp, octave_idx_type idx1, octave_idx_type idx2=0, octave_idx_type idx3=0) { rsb_err_t errval = RSB_ERR_NO_ERROR; if( idx1 > RSBOI_SIZEMAX || idx2 > RSBOI_SIZEMAX || idx3 > RSBOI_SIZEMAX ) errval = RSB_ERR_LIMITS; if( errvalp ) *errvalp = errval; return errval; } static void rsboi_oi2ri( octave_idx_type * IP, rsb_nnz_idx_t nnz) { // octave_idx_type -> rsb_coo_idx_t rsb_coo_idx_t * RP = (rsb_coo_idx_t *) IP; const octave_idx_type * OP = (const octave_idx_type*) IP; rsb_nnz_idx_t nzi; for(nzi=0;nzi octave_idx_type const rsb_coo_idx_t * RP = (const rsb_coo_idx_t *) IP; octave_idx_type * OP = (octave_idx_type*) IP; rsb_nnz_idx_t nzi; for(nzi=0;nzimtxAp = RSBOI_NULL; } octave_sparsersb_mtx (const octave_sparse_matrix &sm) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); } #if RSBOI_WANT_MTX_LOAD octave_sparsersb_mtx (const std::string &mtxfilename, rsb_type_t typecode = RSBOI_TYPECODE) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX) { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); if(!(this->mtxAp = rsb_file_mtx_load(mtxfilename.c_str(),RSBOI_RF,typecode,&errval))) #if RSBOI_WANT_VECLOAD_INSTEAD_MTX /* no problem */; #else RSBOI_ERRMSG(RSBOI_0_ALERRMSG); RSBOI_PERROR(errval); if(!this->mtxAp) RSBOI_0_ERROR(RSBOI_0_ALLERRMSG); #endif } #endif //void alloc_rsb_mtx_from_coo_copy(const idx_vector &IM, const idx_vector &JM, const void * SMp, octave_idx_type nrA, octave_idx_type ncA, bool iscomplex=false, rsb_flags_t eflags=RSBOI_DCF) void alloc_rsb_mtx_from_coo_copy(idx_vector & IM, idx_vector & JM, const void * SMp, octave_idx_type nrA, octave_idx_type ncA, bool iscomplex=false, rsb_flags_t eflags=RSBOI_DCF) { const octave_idx_type nnzA = IM.length(); rsb_err_t errval = RSB_ERR_NO_ERROR; #if RSBOI_WANT_DOUBLE_COMPLEX const rsb_type_t typecode = iscomplex?RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX:RSB_NUMERICAL_TYPE_DOUBLE; #else /* RSBOI_WANT_DOUBLE_COMPLEX */ const rsb_type_t typecode = RSBOI_TYPECODE; #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ const octave_idx_type *IA = RSBOI_NULL,*JA = RSBOI_NULL; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); #if RSBOI_WANT_SYMMETRY /* shall verify if any symmetry is present */ #endif IA = (const octave_idx_type*)IM.raw(); JA = (const octave_idx_type*)JM.raw(); //RSB_DO_FLAG_ADD(eflags,rsb_util_determine_uplo_flags(IA,JA,nnzA)); if( (nrA==0 || ncA==0) && RSBOI_SOME_ERROR(errval=rsboi_idxv_overflow( IM, JM ))) goto err; if(!(this->mtxAp = rsboi_mtx_alloc_from_coo_const(SMp,(octave_idx_type*)IA,(octave_idx_type*)JA,nnzA,typecode,nrA,ncA,RSBOI_RB,RSBOI_CB,RSBOI_RF|eflags ,&errval))) RSBOI_ERRMSG(RSBOI_0_ALERRMSG); err: RSBOI_PERROR(errval); if(!this->mtxAp) RSBOI_0_ERROR(RSBOI_0_ALLERRMSG); } #if RSBOI_WANT_DOUBLE_COMPLEX octave_sparsersb_mtx (idx_vector &IM, idx_vector &JM, const ComplexMatrix &SM, octave_idx_type nrA, octave_idx_type ncA, rsb_flags_t eflags) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); this->alloc_rsb_mtx_from_coo_copy(IM,JM,SM.data(),nrA,ncA,true,eflags); } #endif octave_sparsersb_mtx (idx_vector &IM, idx_vector &JM, const Matrix &SM, octave_idx_type nrA, octave_idx_type ncA, rsb_flags_t eflags) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); this->alloc_rsb_mtx_from_coo_copy(IM,JM,SM.data(),nrA,ncA,false,eflags); } void alloc_rsb_mtx_from_csc_copy(const SparseMatrix &sm) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const octave_idx_type nrA = sm.rows (); const octave_idx_type ncA = sm.cols (); const rsb_nnz_idx_t nnzA = sm.nnz(); rsb_err_t errval = RSB_ERR_NO_ERROR; rsb_flags_t eflags = RSBOI_RF; const rsb_type_t typecode = RSB_NUMERICAL_TYPE_DOUBLE; #if RSBOI_WANT_SYMMETRY if(sm.issymmetric()) RSB_DO_FLAG_ADD(eflags,RSB_FLAG_LOWER_SYMMETRIC|RSB_FLAG_TRIANGULAR); // It would be wise to have an isdiag() check and remove symmetry in that case. #endif if(!(this->mtxAp = rsboi_mtx_alloc_from_csc_const(sm.data(),sm.ridx(),sm.cidx(), nnzA,typecode, nrA, ncA, RSBOI_RB, RSBOI_CB, eflags,&errval))) RSBOI_ERRMSG(RSBOI_0_ALLERRMSG); RSBOI_PERROR(errval); if(!this->mtxAp) RSBOI_0_ERROR(RSBOI_0_ALLERRMSG); } octave_sparsersb_mtx (const Matrix &m) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); SparseMatrix sm(m); this->alloc_rsb_mtx_from_csc_copy(sm); } #if RSBOI_WANT_DOUBLE_COMPLEX void alloc_rsb_mtx_from_csc_copy(const SparseComplexMatrix &sm) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const octave_idx_type nrA = sm.rows (); const octave_idx_type ncA = sm.cols (); const octave_idx_type nnzA = sm.nnz (); rsb_err_t errval = RSB_ERR_NO_ERROR; rsb_flags_t eflags = RSBOI_RF; const rsb_type_t typecode = RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX; #if RSBOI_WANT_SYMMETRY if(sm.ishermitian()) { // It would be nice to have SparseComplexMatrix::isdiag() or SparseComplexMatrix::issymmetric() at our disposal here.. bool is_sym = false; if(sm.issquare() && sm.nnz() <= sm.rows()) { SparseComplexMatrix d = sm.diag(); if(!d.all_elements_are_real() && d.nnz() == sm.nnz()) is_sym = true; // diagoanl matrix with non-real on diagonal } if(is_sym) RSB_DO_FLAG_ADD(eflags,RSB_FLAG_LOWER_SYMMETRIC|RSB_FLAG_TRIANGULAR); else RSB_DO_FLAG_ADD(eflags,RSB_FLAG_LOWER_HERMITIAN|RSB_FLAG_TRIANGULAR); } #endif if(!(this->mtxAp = rsboi_mtx_alloc_from_csc_const(sm.data(),sm.ridx(),sm.cidx(), nnzA,typecode, nrA, ncA, RSBOI_RB, RSBOI_CB, eflags,&errval))) RSBOI_ERRMSG(RSBOI_0_ALLERRMSG); RSBOI_PERROR(errval); if(!this->mtxAp) RSBOI_0_ERROR(RSBOI_0_ALLERRMSG); } octave_sparsersb_mtx (const ComplexMatrix &cm) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); this->alloc_rsb_mtx_from_csc_copy(SparseComplexMatrix(cm)); } octave_sparsersb_mtx (const SparseComplexMatrix &sm, rsb_type_t typecode = RSBOI_TYPECODE) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); this->alloc_rsb_mtx_from_csc_copy(sm); } #endif octave_sparsersb_mtx (const SparseMatrix &sm, rsb_type_t typecode = RSBOI_TYPECODE) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); this->alloc_rsb_mtx_from_csc_copy(sm); } octave_sparsersb_mtx (struct rsb_mtx_t *mtxBp) : octave_sparse_matrix (RSBIO_DEFAULT_CORE_MATRIX), mtxAp(mtxBp) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); if(!this->mtxAp) RSBOI_0_ERROR(RSBOI_0_ALLERRMSG); } octave_sparsersb_mtx (const octave_sparsersb_mtx& T) : octave_sparse_matrix (T) { rsb_err_t errval = RSB_ERR_NO_ERROR; struct rsb_mtx_t *mtxBp = RSBOI_NULL; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); errval = rsb_mtx_clone(&mtxBp,RSB_NUMERICAL_TYPE_SAME_TYPE,RSB_TRANSPOSITION_N,RSBOI_NULL,T.mtxAp,RSBOI_EXPF); RSBOI_PERROR(errval); this->mtxAp = mtxBp; }; octave_idx_type length (void) const { return this->nnz(); } octave_idx_type nelem (void) const { return this->nnz(); } octave_idx_type numel (void) const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return this->nnz(); } octave_idx_type nnz (void) const { rsb_nnz_idx_t nnzA = 0; RSBOI_0_EMCHECK(this->mtxAp); rsb_mtx_get_info(this->mtxAp,RSB_MIF_MATRIX_NNZ__TO__RSB_NNZ_INDEX_T,&nnzA); return nnzA;} dim_vector dims (void) const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return (dim_vector(this->rows(),this->cols())); } octave_idx_type dim1 (void) const { return this->rows(); } octave_idx_type dim2 (void) const { return this->cols(); } octave_idx_type rows (void) const { rsb_coo_idx_t Anr=0; RSBOI_0_EMCHECK(this->mtxAp); rsb_mtx_get_info(this->mtxAp,RSB_MIF_MATRIX_ROWS__TO__RSB_COO_INDEX_T,&Anr); return Anr;} octave_idx_type cols (void) const { rsb_coo_idx_t Anc=0; RSBOI_0_EMCHECK(this->mtxAp); rsb_mtx_get_info(this->mtxAp,RSB_MIF_MATRIX_COLS__TO__RSB_COO_INDEX_T,&Anc); return Anc;} rsb_flags_t rsbflags(void) const { rsb_flags_t Aflags=0; RSBOI_0_EMCHECK(this->mtxAp); rsb_mtx_get_info(this->mtxAp,RSB_MIF_MATRIX_FLAGS__TO__RSB_FLAGS_T,&Aflags); return Aflags;} rsb_type_t rsbtype(void) const { rsb_type_t Atype=0; RSBOI_0_EMCHECK(this->mtxAp); rsb_mtx_get_info(this->mtxAp,RSB_MIF_MATRIX_TYPECODE__TO__RSB_TYPE_T,&Atype); return Atype;} //octave_idx_type rows (void) const { RSBOI_0_EMCHECK(this->mtxAp);return this->mtxAp->nrA; } //octave_idx_type cols (void) const { RSBOI_0_EMCHECK(this->mtxAp);return this->mtxAp->ncA; } octave_idx_type columns (void) const { return this->cols(); } octave_idx_type nzmax (void) const { return this->nnz(); } octave_idx_type capacity (void) const { return this->nnz(); } size_t byte_size (void) const { RSBOI_0_EMCHECK(this->mtxAp);size_t so=0;rsb_mtx_get_info(this->mtxAp,RSB_MIF_TOTAL_SIZE__TO__SIZE_T,&so);return so; } virtual ~octave_sparsersb_mtx (void) { RSBOI_DEBUG_NOTICE("destroying librsb matrix %p\n",this->mtxAp); RSBOI_DESTROY(this->mtxAp); } virtual octave_base_value *clone (void) const { RSBOI_DEBUG_NOTICE("cloning librsb matrix %p\n",this->mtxAp); return new octave_sparsersb_mtx (*this); } virtual octave_base_value *empty_clone (void) const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return new octave_sparsersb_mtx (); } virtual SparseMatrix sparse_matrix_value(bool = false)const { struct rsboi_coo_matrix_t rcm; rsb_err_t errval = RSB_ERR_NO_ERROR; rsb_nnz_idx_t nzi; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_0_EMCHECK(this->mtxAp); const rsb_nnz_idx_t nnzA = this->nnz(); #if RSBOI_WANT_EXPAND_SYMM const rsb_nnz_idx_t e = (is__symmetric() || is__hermitian()) ? 2 : 1; rsb_nnz_idx_t nze = 0; #else const rsb_nnz_idx_t e = 1; const rsb_nnz_idx_t nze = 0; #endif Array IA( dim_vector(1,nnzA*e) ); Array JA( dim_vector(1,nnzA*e) ); Array VA( dim_vector(1,nnzA*e) ); rcm.IA = (octave_idx_type*)IA.data(); rcm.JA = (octave_idx_type*)JA.data(); if(!this->is_real_type()) { Array VAC( dim_vector(1,nnzA*e) ); RSBOI_T* VAp = ((RSBOI_T*)VA.data()); rcm.VA = (RSBOI_T*)VAC.data(); errval = rsboi_mtx_get_coo(this->mtxAp,rcm.VA,rcm.IA,rcm.JA,RSB_FLAG_C_INDICES_INTERFACE); for(nzi=0;nzimtxAp,rcm.VA,rcm.IA,rcm.JA,RSB_FLAG_C_INDICES_INTERFACE); } RSBOI_PERROR(errval); #if RSBOI_WANT_EXPAND_SYMM if(e==2) { for(nzi=0;nzirows(); rcm.ncA = this->cols(); return SparseMatrix(VA,IA,JA,rcm.nrA,rcm.ncA); } virtual Matrix matrix_value(bool = false)const { RSBOI_FIXME("inefficient!"); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const Matrix cm = this->sparse_matrix_value().matrix_value(); return cm; } virtual Matrix full_sym_real_value(void)const { // Conversion to full, with symmetry expansion. RSBOI_FIXME("inefficient (see transpose)!"); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const octave_idx_type rn = this->rows(), cn = this->cols(); Matrix v2(rn,cn,RSBOI_ZERO); rsb_err_t errval = RSB_ERR_NO_ERROR; errval |= rsb_mtx_add_to_dense(&rsboi_pone,this->mtxAp,rn,rn,cn,RSB_BOOL_TRUE,(RSBOI_T*)v2.data()); rsboi_error(errval); for(int i = 0; imtxAp,rn,rn,cn,RSB_BOOL_TRUE,(RSBOI_T*)v2.data()); if(RSBOI_SOME_ERROR(errval)) RSBOI_0_ERROR(RSBOI_0_NOCOERRMSG); return v2; } virtual ComplexMatrix full_sym_cplx_value(void)const { // Conversion to full, with symmetry expansion. RSBOI_FIXME("inefficient (see transpose)!"); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const octave_idx_type rn = this->rows(), cn = this->cols(); ComplexMatrix v2(rn,cn,RSBOI_ZERO); rsb_err_t errval = RSB_ERR_NO_ERROR; errval |= rsb_mtx_add_to_dense(&rsboi_pone,this->mtxAp,rn,rn,cn,RSB_BOOL_TRUE,(RSBOI_T*)v2.data()); rsboi_error(errval); for(int i = 0; imtxAp,rn,rn,cn,RSB_BOOL_TRUE,(RSBOI_T*)v2.data()); if(RSBOI_SOME_ERROR(errval)) RSBOI_0_ERROR(RSBOI_0_NOCOERRMSG); return v2; } virtual octave_value full_value(void)const { RSBOI_FIXME("inefficient!"); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); if(is__symmetric() || is__hermitian()) { if(this->is_real_type()) return this->full_sym_real_value(); else return this->full_sym_cplx_value(); } else { if(this->is_real_type()) return this->matrix_value(); else return this->complex_matrix_value(); } } #if RSBOI_WANT_DOUBLE_COMPLEX virtual ComplexMatrix complex_matrix_value(bool = false)const { RSBOI_FIXME("inefficient!"); const octave_sparse_complex_matrix ocm = this->sparse_complex_matrix_value(); const ComplexMatrix cm = ocm.complex_matrix_value(); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return cm; } virtual SparseComplexMatrix sparse_complex_matrix_value(bool = false)const { struct rsboi_coo_matrix_t rcm; rsb_err_t errval = RSB_ERR_NO_ERROR; rsb_nnz_idx_t nzi; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_0_EMCHECK(this->mtxAp); const rsb_nnz_idx_t nnzA = this->nnz(); #if RSBOI_WANT_EXPAND_SYMM const rsb_nnz_idx_t e = (is__symmetric() || is__hermitian()) ? 2 : 1; rsb_nnz_idx_t nze = 0; #else const rsb_nnz_idx_t e = 1; const rsb_nnz_idx_t nze = 0; #endif Array IA( dim_vector(1,nnzA*e) ); Array JA( dim_vector(1,nnzA*e) ); Array VA( dim_vector(1,nnzA*e) ); RSBOI_T* VAp = ((RSBOI_T*)VA.data()); rcm.IA = (octave_idx_type*)IA.data(); rcm.JA = (octave_idx_type*)JA.data(); rcm.VA = VAp; errval = rsboi_mtx_get_coo(this->mtxAp,rcm.VA,rcm.IA,rcm.JA,RSB_FLAG_C_INDICES_INTERFACE); RSBOI_PERROR(errval); if(this->is_real_type()) for(nzi=0;nziis_real_type()) rcm.VA[nnzA+nze]=rcm.VA[nzi]; else { if(is__hermitian()) ((Complex*)rcm.VA)[nnzA+nze]=conj(((Complex*)rcm.VA)[nzi]); else ((Complex*)rcm.VA)[nnzA+nze]= (((Complex*)rcm.VA)[nzi]); } rcm.JA [nnzA+nze] = rcm.IA[nzi]; rcm.IA [nnzA+nze] = rcm.JA[nzi]; nze++; } } VA.resize1(nnzA + nze); IA.resize1(nnzA + nze); JA.resize1(nnzA + nze); #endif rcm.nrA = this->rows(); rcm.ncA = this->cols(); return SparseComplexMatrix(VA,IA,JA,rcm.nrA,rcm.ncA); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ //octave_value::assign_op, int, int, octave_value (&)(const octave_base_value&, const octave_base_value&) //octave_value::assign_op, int, int, octave_value (&) //octave_value assign_op (const octave_base_value&, const octave_base_value&) {} // octave_value::assign_op octave_value::binary_op_to_assign_op (binary_op op) { assign_op retval; return retval; } #if RSBOI_WANT_SUBSREF octave_value do_index_op_subsparse(const idx_vector & i) const { // Convert to Octave's sparse and reconvert. // check with // octave --eval "nnz(sparse((toeplitz(sparsersb([0,1,2,3]))-toeplitz(sparse([0,1,2,3])))))==0" RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); octave_value retval; if(is_real_type()) retval = new octave_sparsersb_mtx ( SparseMatrix(sparse_matrix_value().index(i)) ); else retval = new octave_sparsersb_mtx ( SparseComplexMatrix(sparse_complex_matrix_value().index(i)) ); return retval; } octave_value do_index_op(const octave_value_list& idx, bool resize_ok = false) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); rsb_err_t errval = RSB_ERR_NO_ERROR; octave_value retval; //if (type.length () == 1) { const octave_idx_type n_idx = idx.length (); if (n_idx == 0 ) retval = clone(); else if (n_idx == 1 ) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); #if RSBOI_WANT_SPMTX_SUBSREF const octave_value_list ovl = idx; if(ovl(0).issparse()) { SparseBoolMatrix sm = SparseBoolMatrix (ovl(0).sparse_matrix_value()); const octave_idx_type * ir = sm.mex_get_ir (); const octave_idx_type * jc = sm.mex_get_jc (); const octave_idx_type nr = sm.rows (); const octave_idx_type nc = sm.cols (); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); for (octave_idx_type j = 0; j < nc; j++) { std::cout << jc[j] << ".." << jc[j+1] << "\n"; for (octave_idx_type i = jc[j]; i < jc[j+1]; i++) { std::cout << ir[i] << " " << j << "\n"; } } RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); retval = octave_value(this->clone()); // matches but .. heavy ?! } else #endif /* RSBOI_WANT_SPMTX_SUBSREF */ { const idx_vector i = idx (0).index_vector (); #if defined(RSB_LIBRSB_VER) && (RSB_LIBRSB_VER< 10100) const octave_idx_type ii = i(0); RSBOI_ERRMSG("You are using a very old and limited version of librsb: no support for this kind of access\n"); #elif defined(RSB_LIBRSB_VER) && (RSB_LIBRSB_VER>=10100) #if RSBOI_WANT_RESHAPE if( i.is_colon() ) { retval = this->reshape(dim_vector (this->rows()*this->cols(),1)); goto err; } if( i.is_range() ) { if(is_real_type()) retval = new octave_sparsersb_mtx ( SparseMatrix(sparse_matrix_value().index(i)) ); else retval = new octave_sparsersb_mtx ( SparseComplexMatrix(sparse_complex_matrix_value().index(i)) ); goto err; } #endif /* RSBOI_WANT_RESHAPE */ RSBOI_DEBUG_NOTICE("i.length () = %d\n",i.length()); if(i.length()>1) { retval = do_index_op_subsparse(i); goto err; } #if RSBOI_WANT_OS_1D_IDX_ACCESS const rsb_coo_idx_t jj = (i(0) / rows()); const rsb_coo_idx_t ii = (i(0) % rows()); RSBOI_DEBUG_NOTICE("get_element (%d,%d)\n",ii,ii); if(is_real_type()) { RSBOI_T rv; //errval = rsb_do_get_nnz_element(this->mtxAp,&rv,RSBOI_NULL,RSBOI_NULL,ii); errval = rsb_mtx_get_values(this->mtxAp,&rv,&ii,&jj,1,RSBOI_NF); retval = rv; } else { Complex rv { RSBOI_ZERO, RSBOI_ZERO }; //errval = rsb_do_get_nnz_element(this->mtxAp,&rv,RSBOI_NULL,RSBOI_NULL,ii); errval = rsb_mtx_get_values(this->mtxAp,&rv,&ii,&jj,1,RSBOI_NF); retval = rv; } if(RSBOI_SOME_ERROR(errval)) { if(ii>=this->rows() || ii<0 || jj>=this->cols() || jj<0) error ("trying accessing element %ld,%ld: index out of bounds !",(long int)ii+1,(long int)jj+1); else ; /* likely a zero */ } #endif /* RSBOI_WANT_OS_1D_IDX_ACCESS */ #endif } } else if (n_idx == 2 ) { RSBOI_TRY_BLK { const idx_vector i = idx (0).index_vector (); RSBOI_IF_NERR_STATE() { #if RSBOI_WANT_SYMMETRY /* Will expand (:,:) but won't access empty-triangle nonzeros. */ #endif #if RSBOI_WANT_RESHAPE if( idx(0).index_vector ().is_colon() || idx(1).index_vector ().is_colon() ) { if(is_real_type()) { octave_sparse_matrix osm (sparse_matrix_value()); retval = osm.do_index_op(idx); } else { octave_sparse_complex_matrix osm (sparse_complex_matrix_value()); retval = osm.do_index_op(idx); } goto err; } #endif /* RSBOI_WANT_RESHAPE */ if(is_real_type()) { const idx_vector j = idx (1).index_vector (); RSBOI_T rv; rsb_coo_idx_t ii = -1, jj = -1; ii = i(0); jj = j(0); RSBOI_DEBUG_NOTICE("get_elements (%d %d)\n",ii,jj); errval = rsb_mtx_get_values(this->mtxAp,&rv,&ii,&jj,1,RSBOI_NF); retval = rv; RSBOI_IF_NERR(;) } else { const idx_vector j = idx (1).index_vector (); Complex rv; rsb_coo_idx_t ii =-1, jj = -1; ii = i(0); jj = j(0); RSBOI_DEBUG_NOTICE("get_elements (%d %d) complex\n",ii,jj); errval = rsb_mtx_get_values(this->mtxAp,&rv,&ii,&jj,1,RSBOI_NF); retval = rv; RSBOI_IF_NERR(;) } } } RSBOI_CATCH_BLK } } err: return retval; } #if RSBOI_WANT_RESHAPE octave_value reshape (const dim_vector& new_dims) const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_WARN(RSBOI_0_UNFFEMSG); octave_value retval; if(is_real_type()) retval = new octave_sparsersb_mtx ( sparse_matrix_value().reshape(new_dims) ); else retval = new octave_sparsersb_mtx ( sparse_complex_matrix_value().reshape(new_dims) ); return retval; } #endif /* RSBOI_WANT_RESHAPE */ octave_value subsref (const std::string &type, const std::list& idx) { octave_value retval; const int skip = 1; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_TRY_BLK { switch (type[0]) { case '(': retval = do_index_op(idx.front()); break; case '.': RSBOI_DEBUG_NOTICE("UNFINISHED\n"); break; case '{': error ("%s cannot be indexed with %c", type_name().c_str(), type[0]); break; default: panic_impossible (); } } RSBOI_CATCH_BLK RSBOI_IF_NERR( retval = retval.next_subsref (type, idx, skip); ) err: return retval; } /* subsref */ #else /* RSBOI_WANT_SUBSREF */ /* FIXME: need an alternative, bogus implementation of subsref */ #endif /* RSBOI_WANT_SUBSREF */ octave_value_list dotref (const octave_value_list& idx) { octave_value_list retval; const std::string nm = idx(0).string_value (); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); /* if (nm == "type") if (isupper ()) retval = octave_value ("Upper"); else retval = octave_value ("Lower"); else*/ error ("%s can indexed with .%s", type_name().c_str(), nm.c_str()); return retval; } bool is_map (void) const { return true; } bool issparse(void) const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);return true; } bool is_real_type (void) const { RSBOI_0_EMCHECK(this->mtxAp); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);return this->rsbtype()==RSB_NUMERICAL_TYPE_DOUBLE?true:false; } bool is_diagonal (void) const { RSBOI_0_EMCHECK(this->mtxAp); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);return RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_DIAGONAL)?true:false; }/* FIXME: new: not sure whether this is ever called */ bool is_lower_triangular (void) const { RSBOI_0_EMCHECK(this->mtxAp); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);return RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_LOWER_TRIANGULAR)?true:false; }/* FIXME: new: not sure whether this is ever called */ bool is_upper_triangular (void) const { RSBOI_0_EMCHECK(this->mtxAp); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);return RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_UPPER_TRIANGULAR)?true:false; }/* FIXME: new: not sure whether this is ever called */ bool iscomplex (void) const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return !is_real_type(); } bool isreal (void) const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return is_real_type(); } bool is_bool_type (void) const { return false; } bool isinteger (void) const { return false; } bool is_square (void) const { return this->rows()==this->cols(); } bool is_empty (void) const { return false; } bool is__symmetric (void) const { if(RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_SYMMETRIC))return true; return false; } bool is__hermitian (void) const { if(RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_HERMITIAN))return true; return false; } std::string get_symmetry (void) const { return (RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_SYMMETRIC)?"S": (RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_HERMITIAN)?"H":"U")); } bool is__triangular (void) const { rsb_bool_t retval = RSB_BOOL_FALSE; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); if(!this->mtxAp) retval = RSB_BOOL_FALSE; else #if RSBOI_WANT_SYMMETRY if( (!RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_SYMMETRIC)) || RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_DIAGONAL) ) #endif retval = RSB_DO_FLAG_HAS(this->rsbflags(),RSB_FLAG_TRIANGULAR)?RSB_BOOL_TRUE:RSB_BOOL_FALSE; return retval; } // int is_struct (void) const { return false; } bool save_ascii (std::ostream& os) { error ("%s", "save_ascii() " RSBOI_0_NIYERRMSG); return false; } bool load_ascii (std::istream& is) { error ("%s", "load_ascii() " RSBOI_0_NIYERRMSG); return false; } bool save_binary (std::ostream& os, bool& save_as_floats) { error ("%s", "save_binary() " RSBOI_0_NIYERRMSG); return false; } #if RSBOI_USE_PATCH_OCT44 bool load_binary (std::istream& is, bool swap, octave::mach_info::float_format fmt) #else /* RSBOI_USE_PATCH_OCT44 */ // would break on octave6 bool load_binary (std::istream& is, bool swap, oct_mach_info::float_format fmt) #endif /* RSBOI_USE_PATCH_OCT44 */ { error ("%s", "load_binary() " RSBOI_0_NIYERRMSG); return false; } octave_value subsasgn (const std::string& type, const std::list& idx, const octave_value& rhs) { octave_value retval; #if 0 rsb_err_t errval = RSB_ERR_NO_ERROR; #endif RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); switch (type[0]) { case '(': { if (type.length () == 1) { //retval = numeric_assign (type, idx, rhs); //RSBOI_DEBUG_NOTICE("UNFINISHED\n"); const octave_idx_type n_idx = idx.front().length (); switch (n_idx) { case 0: retval = matrix; RSBOI_DEBUG_NOTICE("UNFINISHED\n"); break; case 1: { #if RSBOI_WANT_SPMTX_SUBSASGN { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const octave_value_list ovl = idx.front(); if(ovl(0).issparse() && ovl(0).isreal() && rhs.isreal()) { const SparseBoolMatrix sm = SparseBoolMatrix (ovl(0).sparse_matrix_value()); const octave_idx_type * ir = sm.mex_get_ir (); const octave_idx_type * jc = sm.mex_get_jc (); const octave_idx_type nc = sm.cols (); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const RSBOI_T rv = rhs.double_value(); for (octave_idx_type j = 0; j < nc; j++) { for (octave_idx_type i = jc[j]; i < jc[j+1]; i++) { rsb_err_t errval = RSB_ERR_NO_ERROR; const rsb_coo_idx_t ii = static_cast(ir[i]); // Note: potentioally dangerous casts, if types are different and matrix huge. const rsb_coo_idx_t jj = static_cast(j); errval = rsb_mtx_set_values(this->mtxAp,&rv,&ii,&jj,1,RSBOI_NF); if(RSBOI_SOME_ERROR(errval)) error ("%s", "FIXME: Incomplete: Can only accept already existing indices."); } } RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); retval = octave_value(this->clone()); } else error ("%s", "FIXME: Incomplete: no complex sparse-sparse update for the moment."); } #else /* RSBOI_WANT_SPMTX_SUBSASGN */ RSBOI_DEBUG_NOTICE("UNFINISHED\n"); idx_vector i = idx.front()(0).index_vector (); // ... RSBOI_IF_NERR( ;//retval = octave_value (matrix.index (i, resize_ok)); ) #endif /* RSBOI_WANT_SPMTX_SUBSASGN */ } break; default: { if (n_idx == 2 ) { idx_vector i = idx.front() (0).index_vector (); idx_vector j = idx.front() (1).index_vector (); #if 0 // for op_el_div_eq and op_el_mul_eq std :: cout << "ic2 " << i.is_colon() << "\n" ; if( i.is_colon() && !j.is_colon() ) { ComplexMatrix cm = rhs.complex_matrix_value(); std :: cout << " : , .\n"; errval=rsb_mtx_upd_values(this->mtxAp,RSB_ELOPF_SCALE_ROWS,cm.data()); } if(!i.is_colon() && j.is_colon() ) { std :: cout << " . , :\n"; } if( i.is_colon() && j.is_colon() ) { std :: cout << " : , :\n"; } #endif RSBOI_IF_NERR_STATE() { if(is_real_type()) { rsb_err_t errval = RSB_ERR_NO_ERROR; rsb_coo_idx_t ii = -1, jj = -1; RSBOI_T rv = rhs.double_value(); ii = i(0); jj = j(0); RSBOI_DEBUG_NOTICE("update elements (%d %d)\n",ii,jj); #if RSBOI_WANT_SYMMETRY /* FIXME: and now ? */ #endif errval = rsb_mtx_set_values(this->mtxAp,&rv,&ii,&jj,1,RSBOI_NF); RSBOI_PERROR(errval); /* FIXME: I am unsure, here */ //retval=rhs.double_value(); // this does not match octavej //retval=octave_value(this); retval = octave_value(this->clone()); // matches but .. heavy ?! RSBOI_IF_NERR( ;//retval = octave_value (matrix.index (i, j, resize_ok)); ) } else { rsb_err_t errval = RSB_ERR_NO_ERROR; rsb_coo_idx_t ii = -1, jj = -1; Complex rv = rhs.complex_value(); ii = i(0); jj = j(0); RSBOI_DEBUG_NOTICE("update elements (%d %d) complex\n",ii,jj); #if RSBOI_WANT_SYMMETRY /* FIXME: and now ? */ #endif errval = rsb_mtx_set_values(this->mtxAp,&rv,&ii,&jj,1,RSBOI_NF); RSBOI_PERROR(errval); /* FIXME: I am unsure, here */ //retval=rhs.double_value(); // this does not match octavej //retval=octave_value(this); retval = octave_value(this->clone()); // matches but .. heavy ?! RSBOI_IF_NERR( ;//retval = octave_value (matrix.index (i, j, resize_ok)); ) } // class octave_map; // retval = octave_map(); // RSBOI_DEBUG_NOTICE("UNFINISHED: set %d %d <- %lg\n",ii,jj,rhs.double_value()); } } } break; } } else if (type.length () == 2) { std::list::const_iterator p = idx.begin (); octave_value_list key_idx = *++p; std::string key = key_idx(0).string_value (); RSBOI_DEBUG_NOTICE("UNFINISHED\n"); if (key == "type") error ("%s", "use 'sparse_rsb' to set type"); else error ("%s can indexed with .%s", type_name().c_str(), key.c_str()); } else error ("in indexed assignment of %s, illegal assignment", type_name().c_str ()); } break; case '.': { octave_value_list key_idx = idx.front (); std::string key = key_idx(0).string_value (); RSBOI_DEBUG_NOTICE("UNFINISHED\n"); if (key == "type") error ("%s", "use 'sparse_rsb' to set matrix type"); else error ("%s can indexed with .%s", type_name().c_str(), key.c_str()); } break; case '{': RSBOI_DEBUG_NOTICE("UNFINISHED\n"); error ("%s cannot be indexed with %c", type_name().c_str (), type[0]); break; default: panic_impossible (); } return retval; } /* subsasgn */ octave_base_value *try_narrowing_conversion (void) { octave_base_value *retval = 0; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); return retval; } /* type_conv_fcn numeric_conversion_function (void) const { } */ type_conv_info numeric_conversion_function (void) const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return default_numeric_conversion_function; } std::string get_info_string() { char ss[RSBOI_INFOBUF]; rsb_mtx_get_info_str(this->mtxAp,"RSB_MIF_MATRIX_INFO__TO__CHAR_P",ss,RSBOI_INFOBUF); return ss; } #if defined(OCTAVE_MAJOR_VERSION) && (OCTAVE_MAJOR_VERSION>=4) void print (std::ostream& os, bool pr_as_read_syntax = false) #else /* OCTAVE_MAJOR_VERSION */ void print (std::ostream& os, bool pr_as_read_syntax = false) const #endif /* OCTAVE_MAJOR_VERSION */ { RSBOI_FIXME("what to do with pr_as_read_syntax ?"); struct rsboi_coo_matrix_t rcm; rsb_err_t errval = RSB_ERR_NO_ERROR; rsb_nnz_idx_t nnzA = this->nnz(),nzi; bool ic = this->is_real_type()?false:true; Array IA( dim_vector(1,nnzA) ); Array JA( dim_vector(1,nnzA) ); Array VA( dim_vector(1,(ic?2:1)*nnzA) ); std::string c = ic ? "complex" : "real"; #if RSBOI_WANT_PRINT_DETAIL char ss[RSBOI_INFOBUF]; rsb_mtx_get_info_str(this->mtxAp,"RSB_MIF_MATRIX_INFO__TO__CHAR_P",ss,RSBOI_INFOBUF); #endif RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); rcm.VA = (RSBOI_T*)VA.data(); rcm.IA = (octave_idx_type*)IA.data(); rcm.JA = (octave_idx_type*)JA.data(); #if RSBOI_WANT_SYMMETRY /* No expansion: we merely mention symmetry. */ #endif if(! (rcm.VA && rcm.IA && rcm.JA) ) // NOTE: might rather want an error () here. nnzA = 0; else errval = rsboi_mtx_get_coo(this->mtxAp,rcm.VA,rcm.IA,rcm.JA,RSB_FLAG_C_INDICES_INTERFACE); if(RSBOI_SOME_ERROR(errval)) { RSBOI_PERROR(errval); return; } rcm.nrA = this->rows(); rcm.ncA = this->cols(); double pct = 100.0*(((RSBOI_T)nnzA)/((RSBOI_T)rcm.nrA))/rcm.ncA; octave_stdout<rsbflags(),RSB_FLAG_HERMITIAN)?"H":"U")) // NOTE: need a mechanism to print out these flags from rsb itself #endif ; #if RSBOI_WANT_PRINT_PCT_OCTAVE_STYLE /* straight from Octave's src/ov-base-sparse.cc */ if (nnzA > 0) { int prec = 2; if (pct == 100) prec = 3; else { if (pct > 99.9) prec = 4; else if (pct > 99) prec = 3; if (pct > 99.99) pct = 99.99; } octave_stdout << " [" << std::setprecision (prec) << pct << "%]"; } #else octave_stdout << " ["< "<<((RSBOI_T*)rcm.VA)[2*nzi+0]<<" + " <<((RSBOI_T*)rcm.VA)[2*nzi+1]<<"i\n"; else for(nzi=0;nzi "<<((RSBOI_T*)rcm.VA)[nzi]<<"\n"; newline(os); RSBIO_NULL_STATEMENT_FOR_COMPILER_HAPPINESS } octave_value diag (octave_idx_type k) const { octave_value retval; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_0_EMCHECK(this->mtxAp); if(k!=0) { error ("%s", "only main diagonal extraction is supported !"); } if(this->is_square()) { rsb_err_t errval = RSB_ERR_NO_ERROR; //RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); if(this->is_real_type()) { Matrix DA(this->rows(),1); errval = rsb_mtx_get_vec(this->mtxAp,(RSBOI_T*)DA.data(),RSB_EXTF_DIAG); retval = (DA); } else { ComplexMatrix DA(this->rows(),1); errval = rsb_mtx_get_vec(this->mtxAp,(RSBOI_T*)DA.data(),RSB_EXTF_DIAG); retval = (DA); } RSBOI_PERROR(errval); } else { error ("%s", RSBOI_0_NSQERRMSG); } return retval; } octave_value rsboi_get_scaled_copy_inv(const RSBOI_T alpha)const { const RSBOI_T one = 1.0; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return rsboi_get_scaled_copy(one/alpha); } #if RSBOI_WANT_DOUBLE_COMPLEX octave_value rsboi_get_scaled_copy_inv(const Complex alpha)const { const Complex one = 1.0; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return rsboi_get_scaled_copy(one/alpha); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ octave_value rsboi_get_scaled_copy(const RSBOI_T alpha, rsb_trans_t transA=RSB_TRANSPOSITION_N)const { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); struct rsb_mtx_t *mtxBp = RSBOI_NULL; if(is_real_type()) { errval = rsb_mtx_clone(&mtxBp,RSB_NUMERICAL_TYPE_SAME_TYPE,transA, &alpha,this->mtxAp,RSBOI_EXPF); } else #if RSBOI_WANT_DOUBLE_COMPLEX { Complex calpha;calpha+=alpha; errval = rsb_mtx_clone(&mtxBp,RSB_NUMERICAL_TYPE_SAME_TYPE,transA,&calpha,this->mtxAp,RSBOI_EXPF); } #else /* RSBOI_WANT_DOUBLE_COMPLEX */ {RSBOI_0_ERROR(RSBOI_0_NOCOERRMSG);} #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ RSBOI_PERROR(errval); return new octave_sparsersb_mtx( mtxBp ); } #if RSBOI_WANT_DOUBLE_COMPLEX octave_value rsboi_get_scaled_copy(const Complex alpha)const { rsb_err_t errval = RSB_ERR_NO_ERROR; octave_sparsersb_mtx *m = RSBOI_NULL; struct rsb_mtx_t *mtxBp = RSBOI_NULL; if(is_real_type()) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); errval = rsb_mtx_clone(&mtxBp,RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX,RSB_TRANSPOSITION_N,&rsboi_pone,this->mtxAp,RSBOI_EXPF); rsboi_error(errval); errval = rsb_mtx_upd_values(mtxBp,RSB_ELOPF_MUL,&alpha); } else { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); errval = rsb_mtx_clone(&mtxBp,RSB_NUMERICAL_TYPE_SAME_TYPE,RSB_TRANSPOSITION_N,&alpha,this->mtxAp,RSBOI_EXPF); } rsboi_error(errval); m = new octave_sparsersb_mtx( mtxBp ); if(!m) error ("%s", "copying matrix failed!"); return m; } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ octave_value scale_rows(const octave_matrix&v2, bool want_div=false) { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); if(this->is_real_type()) { const Matrix rm = want_div?1.0/v2.matrix_value ():v2.matrix_value (); const octave_idx_type b_nc = rm.cols (); const octave_idx_type b_nr = rm.rows (); //octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->columns(); const octave_idx_type nrhs = b_nc; Matrix retval(ldc,nrhs,RSBOI_ZERO); if(this->rows()!=b_nr) { error ("%s", "matrices dimensions do not match!\n"); return Matrix(); } errval = rsb_mtx_upd_values(this->mtxAp,RSB_ELOPF_SCALE_ROWS,rm.data()); RSBOI_PERROR(errval); return retval; } else { const ComplexMatrix cm = want_div?1.0/v2.complex_matrix_value ():v2.complex_matrix_value (); const octave_idx_type b_nc = cm.cols (); const octave_idx_type b_nr = cm.rows (); //const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->columns(); const octave_idx_type nrhs = b_nc; ComplexMatrix retval(ldc,nrhs,RSBOI_ZERO); if(this->rows()!=b_nr) { error ("%s", "matrices dimensions do not match!\n"); return ComplexMatrix(); } errval = rsb_mtx_upd_values(this->mtxAp,RSB_ELOPF_SCALE_ROWS,cm.data()); RSBOI_PERROR(errval); return retval; } } octave_value rsboi_spmm(const octave_matrix&v2)const { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); rsb_trans_t transA = RSB_TRANSPOSITION_N; if(this->is_real_type()) { const Matrix b = v2.matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->rows(); const octave_idx_type nrhs = b_nc; Matrix retval(ldc,nrhs,RSBOI_ZERO); if (this->columns()!=b_nr) { error ("%s", "matrix columns count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,this->mtxAp,nrhs,RSB_OI_DMTXORDER,(RSBOI_T*)b.data(),ldb,&rsboi_pone,(RSBOI_T*)retval.data(),ldc); RSBOI_PERROR(errval); return retval; } else { const ComplexMatrix b = v2.complex_matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->rows(); const octave_idx_type nrhs = b_nc; ComplexMatrix retval(ldc,nrhs,RSBOI_ZERO); if(this->columns()!=b_nr) { error ("%s", "matrix columns count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,this->mtxAp,nrhs,RSB_OI_DMTXORDER,(RSBOI_T*)b.data(),ldb,&rsboi_pone,(RSBOI_T*)retval.data(),ldc); RSBOI_PERROR(errval); return retval; } } octave_value rsboi_spmtm(const octave_matrix&v2)const { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); rsb_trans_t transA = RSB_TRANSPOSITION_T; if(this->is_real_type()) { const Matrix b = v2.matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->columns(); const octave_idx_type nrhs = b_nc; Matrix retval(ldc,nrhs,RSBOI_ZERO); if(this->rows() !=b_nr) { error ("%s", "matrix rows count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,this->mtxAp,nrhs,RSB_OI_DMTXORDER,(RSBOI_T*)b.data(),ldb,&rsboi_pone,(RSBOI_T*)retval.data(),ldc); RSBOI_PERROR(errval); return retval; } else { const ComplexMatrix b = v2.complex_matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->columns(); const octave_idx_type nrhs = b_nc; ComplexMatrix retval(ldc,nrhs,RSBOI_ZERO); if(this->rows() !=b_nr) { error ("%s", "matrix rows count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,this->mtxAp,nrhs,RSB_OI_DMTXORDER,(RSBOI_T*)b.data(),ldb,&rsboi_pone,(RSBOI_T*)retval.data(),ldc); RSBOI_PERROR(errval); return retval; } } octave_value rsboi_spmhm(const octave_matrix&v2)const { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); rsb_trans_t transA = RSB_TRANSPOSITION_C; if(this->is_real_type()) { const Matrix b = v2.matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->columns(); const octave_idx_type nrhs = b_nc; Matrix retval(ldc,nrhs,RSBOI_ZERO); if(this->rows() !=b_nr) { error ("%s", "matrix rows count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,this->mtxAp,nrhs,RSB_OI_DMTXORDER,(RSBOI_T*)b.data(),ldb,&rsboi_pone,(RSBOI_T*)retval.data(),ldc); RSBOI_PERROR(errval); return retval; } else { const ComplexMatrix b = v2.complex_matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->columns(); const octave_idx_type nrhs = b_nc; ComplexMatrix retval(ldc,nrhs,RSBOI_ZERO); if(this->rows() !=b_nr) { error ("%s", "matrix rows count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,this->mtxAp,nrhs,RSB_OI_DMTXORDER,(RSBOI_T*)b.data(),ldb,&rsboi_pone,(RSBOI_T*)retval.data(),ldc); RSBOI_PERROR(errval); return retval; } } #if RSBOI_WANT_DOUBLE_COMPLEX octave_value rsboi_spmm(const octave_complex_matrix&v2)const { // TODO: to avoid e.g. v2.complex_matrix_value, one may use: dim_vector dv = v2.dims(); ... dv(ndims) ... rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const rsb_trans_t transA = RSB_TRANSPOSITION_N; struct rsb_mtx_t *mtxCp = RSBOI_NULL; const ComplexMatrix b = v2.complex_matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->rows(); const octave_idx_type nrhs = b_nc; ComplexMatrix retval(ldc,nrhs,RSBOI_ZERO); // zeroing is in principle unnecessary (we zero in rsb_spmm), but otherwise data may not be allocated. RSBOI_T* Cp =(RSBOI_T*)retval.data(); const RSBOI_T* Bp =(RSBOI_T*)b.data(); if(this->is_real_type()) { errval = rsb_mtx_clone(&mtxCp,RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX,RSB_TRANSPOSITION_N,RSBOI_NULL,this->mtxAp,RSBOI_EXPF); } else{ mtxCp = this->mtxAp; } if(RSBOI_SOME_ERROR(errval)) goto err; if(this->columns()!=b_nr) { error ("%s", "matrix columns count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,mtxCp,nrhs,RSB_OI_DMTXORDER,Bp,ldb,&rsboi_pone,Cp,ldc); if(this->is_real_type()) RSBOI_DESTROY(mtxCp); err: RSBOI_PERROR(errval); return retval; } octave_value rsboi_spmtm(const octave_complex_matrix&v2)const { // TODO: to avoid e.g. v2.complex_matrix_value, one may use: dim_vector dv = v2.dims(); ... dv(ndims) ... rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const rsb_trans_t transA = RSB_TRANSPOSITION_T; struct rsb_mtx_t *mtxCp = RSBOI_NULL; const ComplexMatrix b = v2.complex_matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->columns(); const octave_idx_type nrhs = b_nc; ComplexMatrix retval(ldc,nrhs,RSBOI_ZERO); // zeroing is in principle unnecessary (we zero in rsb_spmm), but otherwise data may not be allocated. RSBOI_T* Cp =(RSBOI_T*)retval.data(); const RSBOI_T* Bp =(RSBOI_T*)b.data(); if(this->is_real_type()) errval = rsb_mtx_clone(&mtxCp,RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX,RSB_TRANSPOSITION_N,RSBOI_NULL,this->mtxAp,RSBOI_EXPF); else mtxCp = this->mtxAp; if(RSBOI_SOME_ERROR(errval)) goto err; if(this->rows() !=b_nr) { error ("%s", "matrix rows count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,mtxCp,nrhs,RSB_OI_DMTXORDER,Bp,ldb,&rsboi_pone,Cp,ldc); if(this->is_real_type()) RSBOI_DESTROY(mtxCp); err: RSBOI_PERROR(errval); return retval; } octave_value rsboi_spmhm(const octave_complex_matrix&v2)const { // TODO: to avoid e.g. v2.complex_matrix_value, one may use: dim_vector dv = v2.dims(); ... dv(ndims) ... rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const rsb_trans_t transA = RSB_TRANSPOSITION_C; struct rsb_mtx_t *mtxCp = RSBOI_NULL; const ComplexMatrix b = v2.complex_matrix_value (); const octave_idx_type b_nc = b.cols (); const octave_idx_type b_nr = b.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = this->columns(); const octave_idx_type nrhs = b_nc; ComplexMatrix retval(ldc,nrhs,RSBOI_ZERO); // zeroing is in principle unnecessary (we zero in rsb_spmm), but otherwise data may not be allocated. RSBOI_T* Cp =(RSBOI_T*)retval.data(); const RSBOI_T* Bp =(RSBOI_T*)b.data(); if(this->is_real_type()) errval = rsb_mtx_clone(&mtxCp,RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX,RSB_TRANSPOSITION_N,RSBOI_NULL,this->mtxAp,RSBOI_EXPF); else mtxCp = this->mtxAp; if(RSBOI_SOME_ERROR(errval)) goto err; if(this->rows() !=b_nr) { error ("%s", "matrix rows count does not match operand rows!\n"); return Matrix(); } errval = rsb_spmm(transA,&rsboi_pone,mtxCp,nrhs,RSB_OI_DMTXORDER,Bp,ldb,&rsboi_pone,Cp,ldc); if(this->is_real_type()) RSBOI_DESTROY(mtxCp); err: RSBOI_PERROR(errval); return retval; } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ octave_value rsboi_spmsp(const octave_sparsersb_mtx&v2)const { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); octave_sparsersb_mtx*sm = new octave_sparsersb_mtx(); octave_value retval = sm; #if RSBOI_WANT_SYMMETRY /* NOTE: no expansion */ #endif /* NOTE: what if they are not both of the same type ? it would be nice to have a conversion.. */ sm->mtxAp = rsb_spmsp(RSBOI_BINOP_PREVAILING_TYPE(*this,v2),RSB_TRANSPOSITION_N,&rsboi_pone,this->mtxAp,RSB_TRANSPOSITION_N,&rsboi_pone,v2.mtxAp,&errval); RSBOI_PERROR(errval); if(!sm->mtxAp) RSBOI_0_ERROR(RSBOI_0_ALLERRMSG); return retval; } octave_value rsboi_sppsp(const RSBOI_T*betap, const octave_sparsersb_mtx&v2)const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); octave_sparsersb_mtx*sm = new octave_sparsersb_mtx(); octave_value retval = sm; rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_FIXME(""); #if RSBOI_WANT_SYMMETRY /* NOTE: no expansion */ #endif if ( RSB_LIBRSB_VER < 10201 && ( RSBOI_BINOP_PREVAILING_TYPE(*this,v2) != this->rsbtype() ) ) { /* Way around a bug fixed in librsb-1.2.0.9 */ struct rsb_mtx_t *mtxCp = RSBOI_NULL; errval = rsb_mtx_clone(&mtxCp,RSBOI_BINOP_PREVAILING_TYPE(*this,v2),RSB_TRANSPOSITION_N,RSBOI_NULL,this->mtxAp,RSBOI_EXPF); if(RSBOI_SOME_ERROR(errval)) goto err; RSBOI_PERROR(errval); sm->mtxAp = rsb_sppsp(RSBOI_BINOP_PREVAILING_TYPE(*this,v2),RSB_TRANSPOSITION_N,&rsboi_pone,mtxCp,RSB_TRANSPOSITION_N,betap,v2.mtxAp,&errval); RSBOI_DESTROY(mtxCp); } else sm->mtxAp = rsb_sppsp(RSBOI_BINOP_PREVAILING_TYPE(*this,v2),RSB_TRANSPOSITION_N,&rsboi_pone,this->mtxAp,RSB_TRANSPOSITION_N,betap,v2.mtxAp,&errval); RSBOI_PERROR(errval); err: if(!sm->mtxAp) RSBOI_0_ERROR(RSBOI_0_ALLERRMSG); return retval; } #if RSBOI_WANT_DOUBLE_COMPLEX octave_value cp_ubop(enum rsb_elopf_t opf, Complex z)const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); rsb_err_t errval = RSB_ERR_NO_ERROR; octave_sparsersb_mtx *m = new octave_sparsersb_mtx(*this); if( is_real_type ()) { struct rsb_mtx_t *mtxCp = RSBOI_NULL; errval = rsb_mtx_clone(&mtxCp,RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX,RSB_TRANSPOSITION_N,RSBOI_NULL,this->mtxAp,RSBOI_EXPF); if(RSBOI_SOME_ERROR(errval)) goto err; errval = rsb_mtx_upd_values(mtxCp,opf,&z); rsboi_error(errval); RSBOI_DESTROY(m->mtxAp); m->mtxAp = mtxCp; } else errval = rsb_mtx_upd_values(m->mtxAp,opf,&z); rsboi_error(errval); err: return m; } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ octave_value cp_ubop(enum rsb_elopf_t opf, void*alphap=RSBOI_NULL)const { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); rsb_err_t errval = RSB_ERR_NO_ERROR; octave_sparsersb_mtx *m = new octave_sparsersb_mtx(*this); if(!m)return m; errval = rsb_mtx_upd_values(m->mtxAp,opf,alphap); rsboi_error(errval); return m; } private: public: DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA };/* end of class octave_sparsersb_mtx definition */ #if 0 octave_value_list find_nonzero_elem_idx (const class octave_sparsersb_mtx & nda, int nargout, octave_idx_type n_to_find, int direction) { // useless octave_value retval; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return retval; } #endif #if defined(RSBOI_USE_PATCH_38143) #define RSBOI_CAST_CONV_ARG(ARGT) /* Seems like in 4.1.0+ CAST_CONV_ARG is not there. */ \ ARGT v = dynamic_cast< ARGT > (a) #define RSBOI_CAST_UNOP_ARG(ARGT) /* Seems like in 4.1.0+ CAST_UNOP_ARG is not there. */ \ RSBOI_CAST_CONV_ARG(ARGT) #define RSB_CAST_BINOP_ARGS(ARGT_V1, ARGT_V2); /* Seems like in 4.1.0+ CAST_BINOP_ARGS is not there. */ \ ARGT_V1 v1 = dynamic_cast< ARGT_V1 > (a1); \ ARGT_V2 v2 = dynamic_cast< ARGT_V2 > (a2); #else /* RSBOI_USE_PATCH_38143 */ #define RSBOI_CAST_CONV_ARG CAST_CONV_ARG #define RSBOI_CAST_UNOP_ARG CAST_UNOP_ARG #define RSB_CAST_BINOP_ARGS CAST_BINOP_ARGS #endif /* RSBOI_USE_PATCH_38143 */ static octave_base_value *default_numeric_conversion_function (const octave_base_value& a) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_CAST_CONV_ARG (const octave_sparsersb_mtx&); RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); RSBOI_WARN(RSBOI_0_UNFFEMSG); if(v.is_real_type()) return new octave_sparse_matrix (v.sparse_matrix_value()); else return new octave_sparse_complex_matrix (v.sparse_complex_matrix_value()); } DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_sparsersb_mtx, RSB_OI_TYPEINFO_STRING, RSB_OI_TYPEINFO_TYPE) DEFCONV (octave_triangular_conv, octave_sparsersb_mtx, matrix) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); RSBOI_CAST_CONV_ARG (const octave_sparsersb_mtx&); return new octave_sparse_matrix (v.matrix_value ()); } #if 0 DEFCONV (octave_sparse_rsb_to_octave_sparse_conv, sparse_rsb_mtx, sparse_matrix) { RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_CAST_CONV_ARG (const octave_sparsersb_mtx&); return new octave_sparse_matrix (v.matrix_value ()); } #endif DEFUNOP (uplus, sparse_rsb_mtx) { RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_CAST_UNOP_ARG (const octave_sparsersb_mtx&); return new octave_sparsersb_mtx (v); } #if 0 DEFUNOP (op_incr, sparse_rsb_mtx) { RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_CAST_UNOP_ARG (const octave_sparsersb_mtx&); const octave_idx_type rn = v.mtxAp->nrA,cn = v.mtxAp->ncA; Matrix v2(rn,cn); octave_value retval = v2; rsb_err_t errval = RSB_ERR_NO_ERROR; errval|=rsb_mtx_add_to_dense(&rsboi_pone,v.mtxAp,rn,rn,cn,RSB_BOOL_TRUE,(RSBOI_T*)v2.data()); //v = octave_ma(idx, v2.matrix_value()); return v2; } DEFUNOP (op_decr, sparse_rsb_mtx) { RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_CAST_UNOP_ARG (const octave_sparsersb_mtx&); const octave_idx_type rn = v.mtxAp->nrA, cn = v.mtxAp->ncA; Matrix v2(rn,cn); octave_value retval = v2; rsb_err_t errval = RSB_ERR_NO_ERROR; errval|=rsb_mtx_add_to_dense(&rsboi_pone,v.mtxAp,rn,rn,cn,RSB_BOOL_TRUE,(RSBOI_T*)v2.data()); //v = octave_ma(idx, v2.matrix_value()); return v2; } #endif DEFUNOP (uminus, sparse_rsb_mtx) { RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_CAST_UNOP_ARG (const octave_sparsersb_mtx&); return v.cp_ubop(RSB_ELOPF_NEG); } DEFUNOP (transpose, sparse_rsb_mtx) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_CAST_UNOP_ARG (const octave_sparsersb_mtx&); return v.rsboi_get_scaled_copy(rsboi_pone[0],RSB_TRANSPOSITION_T); } DEFUNOP (htranspose, sparse_rsb_mtx) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_CAST_UNOP_ARG (const octave_sparsersb_mtx&); return v.rsboi_get_scaled_copy(rsboi_pone[0],RSB_TRANSPOSITION_C); } octave_value rsboi_spsm(const octave_sparsersb_mtx&v1, const octave_matrix&v2, rsb_trans_t transA) { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); if(v1.iscomplex()) { ComplexMatrix retval = v2.complex_matrix_value(); const octave_idx_type b_nc = retval.cols (); const octave_idx_type b_nr = retval.rows (); const octave_idx_type ldb = b_nr; const octave_idx_type ldc = v1.rows(); const octave_idx_type nrhs = b_nc; const octave_idx_type nels = retval.rows()*retval.cols(); errval = rsb_spsm(transA,&rsboi_pone,v1.mtxAp,nrhs,RSB_OI_DMTXORDER,&rsboi_zero,(const RSBOI_T*)retval.data(),ldb,(RSBOI_T*)retval.data(),ldc); if(RSBOI_SOME_ERROR(errval)) { RSBOI_PERROR(errval); if(errval == RSB_ERR_INVALID_NUMERICAL_DATA) error ("%s", RSBOI_0_ZODERRMG); for(octave_idx_type i=0;imtxAp,&alpha); errval = rsb_elemental_op(this->mtxAp,RSB_ELOPF_MUL,&alpha); RSBOI_PERROR(errval); return errval; } rsb_err_t rsboi_scale(Complex alpha) { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); //errval = rsb_elemental_scale(this->mtxAp,&alpha); errval = rsb_elemental_op(this->mtxAp,RSB_ELOPF_MUL,&alpha); RSBOI_PERROR(errval); return errval; } DEFASSIGNOP(rsb_op_div_eq_s, sparse_rsb_mtx, scalar) { RSB_CAST_BINOP_ARGS (octave_sparsersb_mtx &, const octave_scalar&); octave_value retval; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_PERROR(v1.rsboi_scale_inv(v2.scalar_value())); retval = v1.matrix_value(); return retval; } rsb_err_t rsboi_scale_inv(RSBOI_T alpha) { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); //errval = rsb_elemental_scale_inv(this->mtxAp,&alpha); errval = rsb_elemental_op(this->mtxAp,RSB_ELOPF_DIV,&alpha); RSBOI_PERROR(errval); return errval; } rsb_err_t rsboi_scale_inv(Complex alpha) { rsb_err_t errval = RSB_ERR_NO_ERROR; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); //errval = rsb_elemental_scale_inv(this->mtxAp,&alpha); errval = rsb_elemental_op(this->mtxAp,RSB_ELOPF_DIV,&alpha); RSBOI_PERROR(errval); return errval; } #endif DEFBINOP(rsb_el_mul_s, sparse_rsb_mtx, scalar) { RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx &, const octave_scalar&); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return v1.rsboi_get_scaled_copy(v2.scalar_value()); } #if RSBOI_WANT_DOUBLE_COMPLEX DEFBINOP(rsb_el_mul_c, sparse_rsb_mtx, complex) { RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx &, const octave_complex&); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return v1.rsboi_get_scaled_copy(v2.complex_value()); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ DEFBINOP(rsb_el_div_s, sparse_rsb_mtx, scalar) { RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx &, const octave_scalar&); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return v1.rsboi_get_scaled_copy_inv(v2.scalar_value()); } #if RSBOI_WANT_DOUBLE_COMPLEX DEFBINOP(rsb_el_div_c, sparse_rsb_mtx, complex) { RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx &, const octave_complex&); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return v1.rsboi_get_scaled_copy_inv(v2.complex_value()); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ #if RSBOI_WANT_DOUBLE_COMPLEX #if 0 DEFASSIGNOP(rsb_op_el_div_eq, sparse_rsb_mtx, scalar) { RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx &, const octave_scalar&); std::cout << "rsb_op_el_div_eq!\n"; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); return v1.rsboi_get_scaled_copy_inv(v2.complex_value()); } #endif DEFASSIGNOP(rsb_op_el_mul_eq_sc, sparse_rsb_mtx, matrix) { //rsb_err_t errval = RSB_ERR_NO_ERROR; RSB_CAST_BINOP_ARGS (octave_sparsersb_mtx &, const octave_matrix&); return v1.scale_rows(v2,false); } DEFASSIGNOP(rsb_op_el_div_eq_sc, sparse_rsb_mtx, matrix) { //rsb_err_t errval = RSB_ERR_NO_ERROR; RSB_CAST_BINOP_ARGS (octave_sparsersb_mtx &, const octave_matrix&); return v1.scale_rows(v2,true); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ DEFBINOP(el_pow, sparse_rsb_mtx, scalar) { RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx &, const octave_scalar&); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSBOI_T alpha [] = {v2.scalar_value(),0}; return v1.cp_ubop(RSB_ELOPF_POW,&alpha); } #if RSBOI_WANT_DOUBLE_COMPLEX DEFBINOP(el_pow_c, sparse_rsb_mtx, complex) { RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx &, const octave_complex&); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); Complex alpha = v2.complex_value(); return v1.cp_ubop(RSB_ELOPF_POW,alpha); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ #ifdef RSB_FULLY_IMPLEMENTED DEFASSIGNOP (assigns, sparse_rsb_mtx, scalar) { RSB_CAST_BINOP_ARGS (octave_sparsersb_mtx &, const octave_scalar&); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); v1.assign(idx, v2.matrix_value()); RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); return octave_value(); } #endif DEFBINOP(op_sub, sparse_rsb_mtx, sparse_rsb_mtx) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_sparsersb_mtx&); return v1.rsboi_sppsp(&rsboi_mone[0],v2); } DEFBINOP(op_add, sparse_rsb_mtx, sparse_rsb_mtx) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_sparsersb_mtx&); return v1.rsboi_sppsp(&rsboi_pone[0],v2); } DEFBINOP(op_spmul, sparse_rsb_mtx, sparse_rsb_mtx) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_sparsersb_mtx&); return v1.rsboi_spmsp(v2); } DEFBINOP(op_mul, sparse_rsb_mtx, matrix) { // "*" operator RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_matrix&); //return v1.rsboi_spmm(v2, false); return v1.rsboi_spmm(v2); } DEFBINOP(op_trans_mul, sparse_rsb_mtx, matrix) { // ".'*" operator RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_matrix&); //return v1.rsboi_spmm(v2, true); return v1.rsboi_spmtm(v2); } DEFBINOP(op_herm_mul, sparse_rsb_mtx, matrix) { // "'*" operator RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_matrix&); //return v1.rsboi_spmm(v2, true); return v1.rsboi_spmhm(v2); } #if RSBOI_WANT_DOUBLE_COMPLEX DEFBINOP(op_c_mul, sparse_rsb_mtx, matrix) { // "*" operator RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_complex_matrix&); //return v1.rsboi_spmm(v2, false); return v1.rsboi_spmm(v2); } DEFBINOP(op_c_trans_mul, sparse_rsb_mtx, matrix) { // ".'*" operator RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_complex_matrix&); //return v1.rsboi_spmm(v2, true); return v1.rsboi_spmtm(v2); } DEFBINOP(op_c_herm_mul, sparse_rsb_mtx, matrix) { // "'*" operator RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); RSB_CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_complex_matrix&); //return v1.rsboi_spmm(v2, true); return v1.rsboi_spmhm(v2); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ #if RSBOI_USE_PATCH_OCT44 #define RSBOI_INSTALL_BINOP(op, t1, t2, f) { \ octave::type_info& type_info = octave::__get_type_info__ ("");\ type_info.register_binary_op(octave_value::op, t1::static_type_id (), t2::static_type_id (), CONCAT2 (oct_binop_, f)); } #define RSBOI_INSTALL_ASSIGNOP(op, t1, t2, f) { \ octave::type_info& type_info = octave::__get_type_info__ ("");\ type_info.register_assign_op(octave_value::op, t1::static_type_id (), t2::static_type_id (), CONCAT2 (oct_assignop_, f)); } #define RSBOI_INSTALL_UNOP(op, t1, f) { \ octave::type_info& type_info = octave::__get_type_info__ ("");\ type_info.register_unary_op(octave_value::op, t1::static_type_id (), CONCAT2 (oct_unop_, f)); } #else /* RSBOI_USE_PATCH_OCT44 */ // deprecated; need a wrapper using octave::typeinfo::register_binary_op #define RSBOI_INSTALL_BINOP INSTALL_BINOP // deprecated; need a wrapper using octave::typeinfo::register_assign_op #define RSBOI_INSTALL_ASSIGNOP INSTALL_ASSIGNOP // deprecated; need a wrapper using octave::typeinfo::register_unary_op #define RSBOI_INSTALL_UNOP INSTALL_UNOP #endif /* RSBOI_USE_PATCH_OCT44 */ static void install_sparsersb_ops (void) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); #ifdef RSB_FULLY_IMPLEMENTED /* boolean pattern-based not */ RSBOI_INSTALL_UNOP (op_not, octave_sparsersb_mtx, op_not); /* to-dense operations */ RSBOI_INSTALL_ASSIGNOP (op_asn_eq, octave_sparsersb_mtx, octave_scalar, assigns); /* ? */ RSBOI_INSTALL_UNOP (op_uplus, octave_sparsersb_mtx, uplus); /* elemental comparison, evaluate to sparse or dense boolean matrices */ RSBOI_INSTALL_BINOP (op_eq, octave_sparsersb_mtx, , ); RSBOI_INSTALL_BINOP (op_le, octave_sparsersb_mtx, , ); RSBOI_INSTALL_BINOP (op_lt, octave_sparsersb_mtx, , ); RSBOI_INSTALL_BINOP (op_ge, octave_sparsersb_mtx, , ); RSBOI_INSTALL_BINOP (op_gt, octave_sparsersb_mtx, , ); RSBOI_INSTALL_BINOP (op_ne, octave_sparsersb_mtx, , ); /* pure elemental; scalar and sparse arguments ?! */ // ? RSBOI_INSTALL_BINOP (op_el_ldiv, octave_sparsersb_mtx, , ); RSBOI_INSTALL_BINOP (op_el_ldiv_eq, octave_sparsersb_mtx, , ); // errval = rsb_mtx_upd_values(this->mtxAp,RSB_ELOPF_SCALE_ROWS,cm.data()); RSBOI_INSTALL_BINOP (op_el_mul_eq, octave_sparsersb_mtx, , ); // diagonal subst ?? RSBOI_INSTALL_BINOP (op_el_and, octave_sparsersb_mtx, , ); RSBOI_INSTALL_BINOP (op_el_or, octave_sparsersb_mtx, , ); /* shift operations: they may be left out from the implementation */ RSBOI_INSTALL_BINOP (op_lshift, octave_sparsersb_mtx, , ); RSBOI_INSTALL_BINOP (op_rshift, octave_sparsersb_mtx, , ); #endif // RSBOI_INSTALL_ASSIGNOP (op_el_div_eq, octave_sparsersb_mtx, octave_matrix, rsb_op_el_div_eq_sc); // errval = rsb_mtx_upd_values(this->mtxAp,RSB_ELOPF_SCALE_ROWS,cm.data()); // RSBOI_INSTALL_ASSIGNOP (op_el_mul_eq, octave_sparsersb_mtx, octave_matrix, rsb_op_el_mul_eq_sc); //INSTALL_WIDENOP (octave_sparsersb_mtx, octave_sparse_matrix,octave_sparse_rsb_to_octave_sparse_conv);/* a DEFCONV .. */ //INSTALL_ASSIGNCONV (octave_sparsersb_mtx, octave_sparse_matrix,octave_sparse_matrix);/* .. */ // no need for the following: need a good conversion function, though //RSBOI_INSTALL_UNOP (op_incr, octave_sparsersb_mtx, op_incr); //RSBOI_INSTALL_UNOP (op_decr, octave_sparsersb_mtx, op_decr); RSBOI_INSTALL_BINOP (op_el_mul, octave_sparsersb_mtx, octave_scalar, rsb_el_mul_s); #if RSBOI_WANT_DOUBLE_COMPLEX RSBOI_INSTALL_BINOP (op_el_mul, octave_sparsersb_mtx, octave_complex, rsb_el_mul_c); #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ // RSBOI_INSTALL_ASSIGNOP (op_mul_eq, octave_sparsersb_mtx, octave_scalar, rsb_op_mul_eq_s); // 20110313 not effective // RSBOI_INSTALL_ASSIGNOP (op_div_eq, octave_sparsersb_mtx, octave_scalar, rsb_op_div_eq_s); // 20110313 not effective RSBOI_INSTALL_BINOP (op_el_div, octave_sparsersb_mtx, octave_scalar, rsb_el_div_s); #if RSBOI_WANT_DOUBLE_COMPLEX RSBOI_INSTALL_BINOP (op_el_div, octave_sparsersb_mtx, octave_complex, rsb_el_div_c); #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ RSBOI_INSTALL_BINOP (op_el_pow, octave_sparsersb_mtx, octave_scalar, el_pow); RSBOI_INSTALL_BINOP (op_el_pow, octave_sparsersb_mtx, octave_complex, el_pow_c); RSBOI_INSTALL_UNOP (op_uminus, octave_sparsersb_mtx, uminus); RSBOI_INSTALL_BINOP (op_ldiv, octave_sparsersb_mtx, octave_matrix, ldiv); RSBOI_INSTALL_BINOP (op_el_ldiv, octave_sparsersb_mtx, octave_matrix, el_ldiv); RSBOI_INSTALL_BINOP (op_div, octave_sparsersb_mtx, octave_matrix, div); RSBOI_INSTALL_BINOP (op_div, octave_sparsersb_mtx, octave_scalar, rsb_s_div); #if RSBOI_WANT_DOUBLE_COMPLEX RSBOI_INSTALL_BINOP (op_div, octave_sparsersb_mtx, octave_complex, rsb_c_div); #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ RSBOI_INSTALL_BINOP (op_mul, octave_sparsersb_mtx, octave_scalar, rsb_s_mul); RSBOI_INSTALL_BINOP (op_mul, octave_scalar, octave_sparsersb_mtx, s_rsb_mul); #if RSBOI_WANT_DOUBLE_COMPLEX RSBOI_INSTALL_BINOP (op_mul, octave_sparsersb_mtx, octave_complex, rsb_c_mul); RSBOI_INSTALL_BINOP (op_mul, octave_complex, octave_sparsersb_mtx, c_rsb_mul); RSBOI_INSTALL_BINOP (op_mul, octave_sparsersb_mtx, octave_complex_matrix, op_c_mul); RSBOI_INSTALL_BINOP (op_trans_mul, octave_sparsersb_mtx, octave_complex_matrix, op_c_trans_mul); RSBOI_INSTALL_BINOP (op_herm_mul, octave_sparsersb_mtx, octave_complex_matrix, op_c_herm_mul); RSBOI_INSTALL_BINOP (op_ldiv, octave_sparsersb_mtx, octave_complex_matrix, c_ldiv); RSBOI_INSTALL_BINOP (op_trans_ldiv, octave_sparsersb_mtx, octave_complex_matrix, trans_c_ldiv); #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ #if RSBOI_WANT_POW RSBOI_INSTALL_BINOP (op_pow, octave_sparsersb_mtx, octave_scalar, rsb_s_pow); #endif /* RSBOI_WANT_POW */ RSBOI_INSTALL_BINOP (op_el_div, octave_sparsersb_mtx, octave_matrix, el_div); RSBOI_INSTALL_UNOP (op_transpose, octave_sparsersb_mtx, transpose); RSBOI_INSTALL_UNOP (op_hermitian, octave_sparsersb_mtx, htranspose); RSBOI_INSTALL_ASSIGNOP (op_asn_eq, octave_sparsersb_mtx, octave_sparse_matrix, assign); RSBOI_INSTALL_ASSIGNOP (op_asn_eq, octave_sparsersb_mtx, octave_matrix, assignm); RSBOI_INSTALL_BINOP (op_mul, octave_sparsersb_mtx, octave_matrix, op_mul); //RSBOI_INSTALL_BINOP (op_pow, octave_sparsersb_mtx, octave_matrix, op_pow); RSBOI_INSTALL_BINOP (op_sub, octave_sparsersb_mtx, octave_sparsersb_mtx, op_sub); RSBOI_INSTALL_BINOP (op_add, octave_sparsersb_mtx, octave_sparsersb_mtx, op_add); //RSBOI_INSTALL_BINOP (op_trans_add, octave_sparsersb_mtx, octave_sparsersb_mtx, op_trans_add); RSBOI_INSTALL_BINOP (op_mul, octave_sparsersb_mtx, octave_sparsersb_mtx, op_spmul); RSBOI_INSTALL_BINOP (op_trans_mul, octave_sparsersb_mtx, octave_matrix, op_trans_mul); RSBOI_INSTALL_BINOP (op_herm_mul, octave_sparsersb_mtx, octave_matrix, op_herm_mul); RSBOI_INSTALL_BINOP (op_trans_ldiv, octave_sparsersb_mtx, octave_matrix, trans_ldiv); //RSBOI_INSTALL_BINOP (op_mul_trans, octave_sparsersb_mtx, octave_matrix, op_mul_trans); //RSBOI_INSTALL_BINOP (op_mul_trans, octave_sparsersb_mtx, octave_matrix, op_mul_trans); //RSBOI_INSTALL_BINOP (op_herm_mul, octave_sparsersb_mtx, octave_matrix, op_herm_mul); //RSBOI_INSTALL_BINOP (op_mul_herm, octave_sparsersb_mtx, octave_matrix, op_mul_herm); //RSBOI_INSTALL_BINOP (op_el_not_and, octave_sparsersb_mtx, octave_matrix, op_el_not_and); //RSBOI_INSTALL_BINOP (op_el_not_or , octave_sparsersb_mtx, octave_matrix, op_el_not_or ); //RSBOI_INSTALL_BINOP (op_el_and_not, octave_sparsersb_mtx, octave_matrix, op_el_and_not); //RSBOI_INSTALL_BINOP (op_el_or _not, octave_sparsersb_mtx, octave_matrix, op_el_or _not); } static void install_sparse_rsb (void) { static bool rsboi_initialized = false; RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); if(!rsboi_initialized) { rsb_err_t errval = RSB_ERR_NO_ERROR; if(sparsersb_tester() == false) { goto err; } errval = rsb_lib_init(RSB_NULL_INIT_OPTIONS); if(RSBOI_SOME_ERROR(errval)) { RSBOI_PERROR(errval); goto err; } rsboi_initialized = true; } else ;/* already initialized */ if (!rsboi_sparse_rsb_loaded) { octave_sparsersb_mtx::register_type (); install_sparsersb_ops (); rsboi_sparse_rsb_loaded = true; #if RSBOI_USE_PATCH_OCT44 octave::interpreter::the_interpreter()->mlock(); #else /* RSBOI_USE_PATCH_OCT44 */ mlock(); #endif /* RSBOI_USE_PATCH_OCT44 */ } return; err: RSBIO_NULL_STATEMENT_FOR_COMPILER_HAPPINESS } /* install_sparse_rsb */ DEFUN_DLD (RSB_SPARSERSB_LABEL, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{S} =} " RSBOI_FNS " (@var{A})\n\ @deftypefnx {Loadable Function} {@var{S} =} " RSBOI_FNS " (@var{I}, @var{J}, @var{SV}, @var{M}, @var{N})\n\ @deftypefnx {Loadable Function} {@var{S} =} " RSBOI_FNS " (@var{I}, @var{J}, @var{SV}, @var{M}, @var{N}, @var{NZMAX})\n\ @deftypefnx {Loadable Function} {@var{S} =} " RSBOI_FNS " (@var{I}, @var{J}, @var{SV})\n\ @deftypefnx {Loadable Function} {@var{S} =} " RSBOI_FNS " (@var{M}, @var{N})\n\ @deftypefnx {Loadable Function} {@var{S} =} " RSBOI_FNS " (@var{I}, @var{J}, @var{SV}, @var{M}, @var{N}, \"unique\")\n\ @deftypefnx {Loadable Function} " RSBOI_FNS " (\"set\", @var{OPN}, @var{OPV})\n\ @deftypefnx {Loadable Function} {@var{v} =} " RSBOI_FNS " (@var{S}, \"get\", @var{MIF})\n\ @deftypefnx {Loadable Function} {@var{v} =} " RSBOI_FNS " (@var{S}, @var{QS})\n\ @deftypefnx {Loadable Function} " RSBOI_FNS " (@var{A},\"save\",@var{MTXFILENAME})\n\ @deftypefnx {Loadable Function} {[@var{S}[, @var{nrows}[, @var{NCOLS}[, @var{NNZ}[, @var{REPINFO}[, @var{FIELD}[, @var{SYMMETRY}]]]]]]] =} " RSBOI_FNS " (@var{MTXFILENAME}[, @var{MTXTYPESTRING}])\n\ " RSBOI_10100_DOCH ""\ \ "\n"\ "Create or manipulate sparse matrices using the RSB format provided by librsb, almost as you do with @code{sparse}.\n"\ "\n"\ "If @var{A} is a @code{full} matrix, convert it to a sparse matrix representation,\n\ removing all zero values.\n"\ "If @var{A} is a @code{sparse} matrix, convert it to a sparse matrix representation.\n"\ "\n\ Given the integer index vectors @var{I} and @var{J}, and a 1-by-@code{nnz}\n\ vector of real or complex values @var{SV}, construct the sparse matrix\n\ @code{S(@var{I}(@var{K}),@var{J}(@var{K})) = @var{SV}(@var{K})} with overall\n\ dimensions @var{M} and @var{N}. \n\ \nThe argument\n\ @code{@var{NZMAX}} is ignored but accepted for compatibility with @sc{Matlab} and @code{sparse}.\n\ \n\ If @var{M} or @var{N} are not specified their values are derived from the\n\ maximum index in the vectors @var{I} and @var{J} as given by\n\ @code{@var{M} = max (@var{I})}, @code{@var{N} = max (@var{J})}.\n\ \n\ \ Can load a matrix from a Matrix Market matrix file named @var{MTXFILENAME}. \ The optional argument @var{MTXTYPESTRING} can specify either real (@code{\"D\"}) or complex (@code{\"Z\"}) type. \ Default is real.\n"\ "In the case @var{MTXFILENAME} is @code{\"" RSBOI_LIS "\"}, a string listing the available numerical types with BLAS-style characters will be returned. If the file turns out to contain a Matrix Market dense vector, this will be loaded.\n"\ \ \ "\n\ \ If @code{\"save\"} is specified, saves the sparse matrix as a Matrix Market matrix file named @var{MTXFILENAME}.\n"\ "\n\ \ @strong{Note}: if multiple values are specified with the same\n\ @var{I}, @var{J} indices, the corresponding values in @var{SV} will\n\ be added.\n\ \n\ The following are all equivalent:\n\ \n\ @example\n\ @group\n\ S = " RSBOI_FNS " (I, J, SV, M, N)\n\ S = " RSBOI_FNS " (I, J, SV, M, N, \"summation\")\n\ S = " RSBOI_FNS " (I, J, SV, M, N, \"sum\")\n"\ /*"S = " RSBOI_FNS " (I, J, SV, \"summation\")\n"*/\ /*"S = " RSBOI_FNS " (I, J, SV, \"sum\")\n"*/\ "@end group\n\ @end example\n\ \n\ \ If the optional @code{\"unique\"} keyword is specified instead, then if more than two values are specified for the\n\ same @var{I}, @var{J} indices, only the last value will be used.\n\ \n\ \ If the optional @code{\"symmetric\"} or @code{\"sym\"} keyword follows, then the input will be considered as the tringle of a symmetric matrix.\n\ If the optional @code{\"hermitian\"} or @code{\"her\"} keyword follows, then the input will be considered as the tringle of a hermitian matrix.\n\ If the optional @code{\"general\"} or @code{\"gen\"} keyword follows, then no symmetry hint is being given.\n\ \n\ @code{" RSBOI_FNS " (@var{M}, @var{N})} will create an empty @var{M}-by-@var{N} sparse\n\ matrix and is equivalent to @code{" RSBOI_FNS " ([], [], [], @var{M}, @var{N})}.\n\ \n\ \ \n\ \ If @var{M} or @var{N} are not specified, then @code{@var{M} = max (@var{I})}, @code{@var{N} = max (@var{J})}.\n\ \n\ \ If @var{OPN} is a string representing a valid librsb option name and @var{OPV} is a string representing a valid librsb option value, these will be passed to the @code{rsb_lib_set_opt_str()} function.\n\ \n\ \ If @var{MIF} is a string specifying a valid librsb matrix info string (valid for librsb's @code{rsb_mtx_get_info_from_string()}), then the corresponding value will be returned for matrix @code{@var{S}}, in string @code{@var{V}}. If @var{MIF} is the an empty string (@code{\"\"}), matrix structure information will be returned. As of librsb-1.2, this is debug or internal information. E.g. for @code{\"RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T\"}, a string with the count of internal RSB blocks will be returned.\n\ \n"\ \ /*"If @var{S} is a " RSBOI_FNS " matrix and @var{QS} is a string, @var{QS} will be interpreted as a query string about matrix @var{S}. String @code{@var{V}} will be returned. See librsb's @code{rsb_mtx_get_info_str()}.\n\ @strong{Note}: this feature is still incomplete, and whatever the value of @var{QS}, a general information string will be returned.\n"*/\ \ "If @var{S} is a @code{" RSBOI_FNS "} matrix and @var{QS} is a string, @var{QS} shall be interpreted as a query string about matrix @var{S}. String @code{@var{V}} will be returned with query results. \n @strong{Note}: this feature is to be completed and its syntax reserved for future use. In this version, whatever the value of @var{QS}, a general matrix information string will be returned (like @code{" RSBOI_FNS "(@var{S},\"get\",\"RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T\")} ).\n"\ "\n"\ /*If any of @var{SV}, @var{I} or @var{J} are scalars, they are expanded\n\ to have a common size.\n*/ RSBOI_10100_DOC ""\ "\n\ Long (64 bit) index support is partial: if Octave has been configured for 64 bit indices, @code{" RSBOI_FNS "} will correctly handle and convert matrices/indices that would fit in a 32 bit indices setup, failing on 'larger' ones. \n\ \n\ @strong{Note}: @code{" RSBOI_FNS "} variables behave just as @code{full} or @code{sparse} variables for @strong{most} operators.\n\ But interaction of binary sparse matrix -- sparse matrix operators involving @strong{symmetric} @code{" RSBOI_FNS "} matrices is not complete and may give unexpected results.\n\ \n\ @strong{Note}: \ Multiplication of a @code{" RSBOI_FNS "} variable by a @code{sparse} one (or the other way round) will expand @code{" RSBOI_FNS "}'s symmetry because of conversion to @code{sparse}.\n\ Multiplication of two @code{" RSBOI_FNS "} variables will not undergo any conversion or symmetry expansion (which might come as unexpected).\n\ \n\ @strong{Note}: \ Summation of a @code{" RSBOI_FNS "} variable with a @code{sparse} one (or the other way round) will expand @code{" RSBOI_FNS "}'s symmetry because of conversion to @code{sparse}.\n\ Summation of two @code{" RSBOI_FNS "} variables will not undergo any conversion or symmetry expansion (which might come as unexpected).\n\ \n\ @strong{Note}: \ Accessing a symmetric or hermitian @code{" RSBOI_FNS "} variable at indices falling in the empty triangle will return a zero.\n\ Accessing via (:,:) will imply symmetry/hermitianness expansion and conversion to @code{sparse}.\n\ \n\ @seealso{sparse, full, nnz, rows, columns, tril, triu, istril, istriu, issparse, iscomplex, isreal, issymmetric, ishermitian}\n\ @end deftypefn") { int nargin = args.length (); octave_value_list retval; octave_sparsersb_mtx*osmp = RSBOI_NULL; bool ic0 = nargin>0?(args(0).iscomplex()):false; bool ic3 = nargin>2?(args(2).iscomplex()):false; bool isr = (nargin>0 && args(0).type_name()==RSB_OI_TYPEINFO_STRING); RSBOI_DEBUG_NOTICE("in sparsersb()\n"); if(ic0) { RSBOI_WARN(RSBOI_O_MISSIMPERRMSG); } if(isr) osmp = ((octave_sparsersb_mtx*)(args(0).internal_rep())); if(ic3 || ic0) #if RSBOI_WANT_DOUBLE_COMPLEX RSBOI_WARN(RSBOI_0_UNCFEMSG); #else /* RSBOI_WANT_DOUBLE_COMPLEX */ RSBOI_0_ERROR(RSBOI_0_NOCOERRMSG); #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ install_sparse_rsb(); if( nargin == 3 && args(0).is_string() && args(0).string_value()=="set" && args(1).is_string() && args(2).is_string()) { // sparsersb ("set", OPN, OPV) const auto os = args(1).string_value(); const auto vs = args(2).string_value(); RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); const rsb_err_t errval = rsb_lib_set_opt_str(os.c_str(),vs.c_str()); if(RSBOI_SOME_ERROR(errval)) { error ("failed setting option %s to %s (error %d)!",os.c_str(),vs.c_str(),errval); goto err; } goto ret; } if( nargin >= 2 && args(0).is_string() && args(0).string_value()=="set" /* && args(1).is_string() */ ) { // sparsersb ("set", XXX) error ("%s", "did you intend to set librsb options ? use the correct syntax then ! (third argument missing)"); goto errp; } if( nargin == 2 && args(0).is_string() && args(0).string_value()=="get" && args(1).is_string() ) { // sparsersb ("get", XXX) /* FIXME: unfinished feature ! */ RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); error ("%s", "getting library options still unimplemented!"); goto errp; } #if defined(RSB_LIBRSB_VER) && (RSB_LIBRSB_VER>=10100) if (nargin >= 2 && isr && args(1).is_string() && args(1).string_value()=="autotune") { // sparsersb (S,"autotune"[, TRANSA, NRHS, MAXR, TMAX, TN, SF]) rsb_err_t errval = RSB_ERR_NO_ERROR; /* these are user settable */ rsb_coo_idx_t nrhs = 0; rsb_int_t maxr = 1; rsb_time_t tmax = 2.0; rsb_int_t tn = 0; rsb_real_t sf = 1.0; rsb_trans_t transA = RSB_TRANSPOSITION_N; /* the following may also be user settable in the future */ const void *alphap = RSBOI_NULL; const void *betap = RSBOI_NULL; /* these not */ rsb_flags_t order = RSB_OI_DMTXORDER; const void * Bp = RSBOI_NULL; rsb_nnz_idx_t ldB = 0; rsb_nnz_idx_t ldC = 0; void * Cp = RSBOI_NULL; if (nargin > 2) transA = RSB_CHAR_AS_TRANSPOSITION(args(2).string_value()[0]); if (transA == RSBOI_INVALID_TRANS_CHAR) { RSBOI_0_ERROR(RSBOI_0_WTRANSMSG); goto ret; } if (nargin > 3) nrhs = args(3).scalar_value(); if (nargin > 4) maxr = args(4).scalar_value(); if (nargin > 5) tmax = args(5).scalar_value(); if (nargin > 6) tn = args(6).scalar_value(); if (nargin > 7) sf = args(7).scalar_value(); // ... if(!osmp || !osmp->mtxAp) RSBOI_0_INTERRMSGSTMT(goto ret) if(nargout) { struct rsb_mtx_t *mtxAp = RSBOI_NULL; errval = rsb_mtx_clone(&mtxAp,RSB_NUMERICAL_TYPE_SAME_TYPE,RSB_TRANSPOSITION_N,RSBOI_NULL,osmp->mtxAp,RSBOI_EXPF); rsboi_error(errval); errval = rsb_tune_spmm(&mtxAp,&sf,&tn,maxr,tmax,transA,alphap,RSBOI_NULL,nrhs,order,Bp,ldB,betap,Cp,ldC); rsboi_error(errval); retval.append(new octave_sparsersb_mtx(mtxAp)); } else errval = rsb_tune_spmm(&osmp->mtxAp,&sf,&tn,maxr,tmax,transA,alphap,RSBOI_NULL/*osmp->mtxAp*/,nrhs,order,Bp,ldB,betap,Cp,ldC); rsboi_error(errval); goto ret; } #endif #if defined(RSB_LIBRSB_VER) && (RSB_LIBRSB_VER>=10100) if (nargin >= 3 && isr && args(1).is_string() && args(1).string_value().substr(0,6)=="render" && args(2).is_string()) { // sparsersb (S,"render", FILENAME[, RWIDTH, RHEIGHT]) rsb_err_t errval = RSB_ERR_NO_ERROR; std::string rmf = args(2).string_value(); rsb_coo_idx_t pmWidth = 512, pmHeight = 512; /* Care to update the documentation when changing these. */ rsb_flags_t marf = RSB_MARF_EPS; /* may tell the user to supply a sparsersb matrix in case input is not 'sparse' */ if (nargin > 3) pmWidth = args(3).scalar_value(); if (nargin > 4) pmHeight = args(4).scalar_value(); if(!osmp || !osmp->mtxAp) RSBOI_0_INTERRMSGSTMT(goto ret) if( args(1).string_value() == "renders") marf = RSB_MARF_EPS_S; if( args(1).string_value() == "renderb") marf = RSB_MARF_EPS_B; errval = rsb_mtx_rndr(rmf.c_str(),osmp->mtxAp,pmWidth,pmHeight,marf); if(RSBOI_SOME_ERROR(errval)) { retval.append(std::string("Error returned from rsb_mtx_rndr()")); rsboi_error(errval); } goto ret; } #endif #if RSBOI_WANT_MTX_SAVE if (nargin == 3 && isr && args(1).is_string() && args(1).string_value()=="save" && args(2).is_string()) { // sparsersb (A,"save",MTXFILENAME) rsb_err_t errval = RSB_ERR_NO_ERROR; errval = rsb_file_mtx_save(osmp->mtxAp,args(2).string_value().c_str()); rsboi_error(errval); goto ret; } #endif if (nargin == 3 && isr && args(1).is_string() && args(1).string_value()=="get" && args(2).is_string()) { // sparsersb (S, "get", MIF) // For any version of lirsb, you can get valid values with e.g.: // grep RSB_MIF path-to/rsb.h | sed 's/^[, ]*//g;s/\([A-Z_]\+\).*<\(.\+\)(.*$/\1: \2/g;s/$/;/g' rsb_err_t errval = RSB_ERR_NO_ERROR; char is[RSBOI_INFOBUF]; char ss[RSBOI_INFOBUF]; if(!osmp || !osmp->mtxAp) RSBOI_0_INTERRMSGSTMT(goto ret) if(strlen(args(2).string_value().c_str())==0) strncpy(is,"RSB_MIF_MATRIX_INFO__TO__CHAR_P",sizeof(is)); else strncpy(is,args(2).string_value().c_str(),sizeof(is)); errval = rsb_mtx_get_info_str(osmp->mtxAp,is,ss,RSBOI_INFOBUF); if(!RSBOI_SOME_ERROR(errval)) { retval.append(octave_value(ss)); goto ret; } if(RSBOI_SOME_ERROR(errval)) { retval.append(std::string("Error returned from rsb_mtx_get_info_from_string()")); } goto ret; } if ( nargin >= 3 && isr && args(1).is_string() && args(1).string_value()=="get" /* && args(1).is_string() */ ) { // sparsersb (S, "get", MIF, XXX) error ("%s", "did you intend to get matrices information ? use the correct syntax then !"); goto errp; } if ( nargin == 1 || nargin == 2 ) { rsb_type_t typecode = RSBOI_TYPECODE; if (nargin >= 2)/* FIXME: this is weird ! */ #if RSBOI_WANT_DOUBLE_COMPLEX typecode = RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX; #else /* RSBOI_WANT_DOUBLE_COMPLEX */ RSBOI_0_ERROR(RSBOI_0_NOCOERRMSG); #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ if (nargin == 2 && isr && args(1).is_string()) #if RSBOI_WANT_QSI { // sparsersb (S, QS) char ss[RSBOI_INFOBUF]; rsb_err_t errval = RSB_ERR_NO_ERROR; if(!osmp || !osmp->mtxAp) RSBOI_0_INTERRMSGSTMT(goto ret) errval = rsb_mtx_get_info_str(osmp->mtxAp,"RSB_MIF_MATRIX_INFO__TO__CHAR_P",ss,RSBOI_INFOBUF); if(!RSBOI_SOME_ERROR(errval)) retval.append(ss); /* TODO, FIXME: to add interpretation (we are ignoring args(1) !): this is to be extended. */ RSBOI_WARN(RSBOI_0_UNFFEMSG);/* FIXME: this is yet unfinished */ // octave_stdout << "Matrix information (in the future, supplementary information may be returned, as more inquiry functionality will be implemented):\n" << ss << "\n"; /* FIXME: shall not print out, but rather return the info as a string*/ //retval.append("place info string here !\n"); goto ret; } #else /* RSBOI_WANT_QSI */ { // sparsersb (S, QS) error ("%s", "invocation error !"); goto errp; } #endif /* RSBOI_WANT_QSI */ else if(args(0).issparse()) { // sparsersb (sparse(...), ...) if( isr ) { RSBOI_WARN(RSBOI_0_UNFFEMSG); retval.append(osmp = (octave_sparsersb_mtx*)(args(0).get_rep()).clone()); } else { if(!ic0) { const SparseMatrix m = args(0).sparse_matrix_value(); RSBOI_IF_ERR( goto err;) retval.append(osmp = new octave_sparsersb_mtx(m,typecode)); } #if RSBOI_WANT_DOUBLE_COMPLEX else { const SparseComplexMatrix m = args(0).sparse_complex_matrix_value(); RSBOI_IF_ERR( goto err;) retval.append(osmp = new octave_sparsersb_mtx(m,typecode)); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ } } else if(args(0).is_string()) { RSBOI_TRY_BLK { // sparsersb (MTXFILENAME) const std::string mtxfilename = args(0).string_value(); RSBOI_IF_ERR( goto err;) if(mtxfilename == RSBOI_LIS) { //retval.append(RSB_NUMERICAL_TYPE_PREPROCESSOR_SYMBOLS); #if RSBOI_WANT_DOUBLE_COMPLEX retval.append("D Z"); #else /* RSBOI_WANT_DOUBLE_COMPLEX */ retval.append("D"); #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ goto ret; } else { // [S, NROWS, NCOLS, NNZ, REPINFO, FIELD, SYMMETRY] = sparsersb (MTXFILENAME) rsb_type_t typecode = RSBOI_TYPECODE; RSBOI_WARN(RSBOI_0_UNFFEMSG); RSBOI_WARN("shall set the type, here"); if(nargin>1 && args(1).is_string()) { const std::string mtxtypestring = args(1).string_value(); if(mtxtypestring == "complex" || mtxtypestring == "Z") #if RSBOI_WANT_DOUBLE_COMPLEX typecode = RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX; #else RSBOI_0_ERROR(RSBOI_0_NOCOERRMSG); #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ if(mtxtypestring == "real" || mtxtypestring=="D") typecode = RSB_NUMERICAL_TYPE_DOUBLE; } #if RSBOI_WANT_MTX_LOAD osmp = new octave_sparsersb_mtx(mtxfilename,typecode); #else /* RSBOI_WANT_DOUBLE_COMPLEX */ goto ret; /* TODO: need error message here */ #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ if(osmp->mtxAp) retval.append(osmp); else delete osmp; #if RSBOI_WANT_VECLOAD_INSTEAD_MTX if(!osmp->mtxAp) { rsb_nnz_idx_t n = 0; rsb_file_vec_load(mtxfilename.c_str(),typecode,RSBOI_NULL,&n); if(n<1) { // error ("%s", "are you sure you passed a valid Matrix Market vector file ?"); goto err; } if(typecode == RSB_NUMERICAL_TYPE_DOUBLE) { Matrix retvec(n,1,RSBOI_ZERO); rsb_file_vec_load(mtxfilename.c_str(),typecode,(RSBOI_T*)retvec.data(),&n); retval.append(retvec); } #if RSBOI_WANT_DOUBLE_COMPLEX else if(typecode == RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX) { ComplexMatrix retvec(n,1,RSBOI_ZERO); rsb_file_vec_load(mtxfilename.c_str(),typecode,(RSBOI_T*)retvec.data(),&n); retval.append(retvec); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ goto ret; } #endif if(nargout) nargout--; if(nargout) retval.append(osmp->rows()),--nargout; if(nargout) retval.append(osmp->cols()),--nargout; if(nargout) retval.append(osmp->nnz()),--nargout; if(nargout) retval.append(osmp->get_info_string()),--nargout; if(nargout) retval.append((!osmp->iscomplex())?"real":"complex"),--nargout; if(nargout) retval.append(osmp->get_symmetry()),--nargout; } } RSBOI_CATCH_BLK } else { RSBOI_TRY_BLK { if (nargin == 2 && args(0).is_scalar_type() && args(1).is_scalar_type() ) { // sparsersb (M, N) const SparseMatrix m = args(0).sparse_matrix_value(); retval.append(osmp = new octave_sparsersb_mtx(SparseMatrix(args(0).scalar_value(),args(1).scalar_value()))); } else { // sparsersb (A, XXX) if(!ic0) { Matrix m = args(0).matrix_value(); RSBOI_IF_ERR( goto err;) retval.append(osmp = new octave_sparsersb_mtx(m)); } #if RSBOI_WANT_DOUBLE_COMPLEX else { ComplexMatrix m = args(0).complex_matrix_value(); RSBOI_IF_ERR( goto err;) retval.append(osmp = new octave_sparsersb_mtx(m)); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ if(nargin >= 2) { error ("%s", "when initializing from a single matrix, no need for second argument !"); goto errp; } } } RSBOI_CATCH_BLK } } else if (nargin >= 3 && nargin <= 7 && !(args(0).is_string() || args(1).is_string() || args(2).is_string() ) ) { // sparsersb (I, J, SV, M, N, "unique") rsb_flags_t eflags = RSBOI_DCF; rsb_flags_t sflags = RSB_FLAG_NOFLAGS; octave_idx_type nrA = 0, ncA = 0; int sai = 0; // string argument index if (nargin > 3) { if ( nargin < 5) { if(nargin == 4 && args(3).is_string()) goto checked; RSBOI_EERROR(RSBOI_0_BADINVOERRMSG); goto errp; } /* FIXME: integer_type should be also supported here: shouldn't it ?*/ if( (!args(3).is_scalar_type()) || (!args(4).is_scalar_type())) { RSBOI_EERROR(RSBOI_0_BADINVOERRMSG); goto errp; } if( nargin > 5 && ((!args(5).is_string()) && (!args(5).is_scalar_type()))) { RSBOI_EERROR(RSBOI_0_BADINVOERRMSG); goto errp; } } checked: if (nargin >= 5 ) { nrA = args(3).scalar_value();/* FIXME: need index value here! */ ncA = args(4).scalar_value(); if(nrA<=0 || ncA<=0) { RSBOI_EERROR(RSBOI_O_NPMSERR); goto errp; } } if (nargin >= 6 && args(5).is_string()) sai = 5; else if (nargin == 4 && args(3).is_string()) sai = 3; for(;sai>0 && sai= 6 && args(5).isinteger()) { /* we ignore this value for MATLAB compatibility */ } RSBOI_IF_ERR( goto err;) if(!ic3) { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); idx_vector iv = args(0).index_vector (); idx_vector jv = args(1).index_vector (); retval.append(osmp = new octave_sparsersb_mtx( iv, jv, args(2).matrix_value(),nrA,ncA,eflags )); } #if RSBOI_WANT_DOUBLE_COMPLEX else { RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG); idx_vector iv = args(0).index_vector (); idx_vector jv = args(1).index_vector (); retval.append(osmp = new octave_sparsersb_mtx( iv, jv, args(2).complex_matrix_value(),nrA,ncA,eflags )); } #endif /* RSBOI_WANT_DOUBLE_COMPLEX */ } else goto errp; if(!osmp) { RSBOI_WARN(RSBOI_0_NEEDERR); RSBOI_DEBUG_NOTICE(RSBOI_0_FATALNBMSG); } #if RSBOI_WANT_HEAVY_DEBUG if(!rsb_is_correctly_built_rcsr_matrix(osmp->mtxAp)) // function non in rsb.h's API { RSBOI_WARN(RSBOI_0_NEEDERR); RSBOI_DEBUG_NOTICE(RSBOI_0_UNCBERR); } #endif goto err; errp: print_usage (); err: ret: return retval; } /* %!test %! assert( 0==nnz(sparsersb(3,3) .- sparse(3,3)) ) %!test %! assert( 0==nnz(sparsersb([],[],[],3,3 ) .- sparse([],[],[],3,3 )) ) %!test %! assert( 0==nnz(sparsersb([],[],[],3,3,123) .- sparse([],[],[],3,3,321)) ) %!test %! s=sparsersb([2]); %! assert(s==2); %! assert(s!=1) %!test %! s=sparsersb([1,2],[1,1],[11,21],2,2 ); %! assert(nnz(s)==2) %!test %! s=sparsersb([1,2],[1,1],[11,21],2,2,-1 ); %! assert(nnz(s)==2) %!test %! s=sparsersb([1,2],[1,1],[11,21] ); %! assert(nnz(s)==2) %!test %! s=sparsersb(10,10 ); %! assert(nnz(s)==0) %!test %! s=sparsersb([1,1],[1,1],[11,21] ); %! assert(nnz(s)==1) %! assert(s(1,1)==32) %!test %! s=sparsersb([1,1],[1,1],[11,21],2,2,"unique"); %! assert(nnz(s)==1), %! assert(s(1,1)==21) %!test %! sparsersb("set","RSB_IO_WANT_VERBOSE_TUNING","1"); %!test %! sparsersb("set","RSB_IO_WANT_VERBOSE_TUNING","0"); %!test %! wvt=0; %! try %! sparsersb("set","...") %! wvt=1; %! end_try_catch %! assert(wvt==0) %!test %! sparsersb("set","FIXME: WE UNFORTUNATELY STILL SILENTLY IGNORE ERRORS HERE (NO RETURN VALUE)","1"); %!test %! wvt=-1; %! try %! wvt=sparsersb("get","RSB_IO_WANT_VERBOSE_TUNING") %! assert(wvt==0 || wvt ==1) %! end_try_catch %! assert(wvt==-1) %!test %! s=sparsersb([1]); %! assert(sparsersb(s,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")=="1") %!test %! s=sparsersb([1]); %! assert(str2num(sparsersb(s,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T"))==1) %!test %! s=sparsersb([1]); %! assert(str2num(sparsersb(s,"get","RSB_MIF_INDEX_STORAGE_IN_BYTES__TO__SIZE_T"))>1) %!test %! s=sparsersb([1]); %! assert(str2num(sparsersb(s,"get","RSB_MIF_INDEX_STORAGE_IN_BYTES_PER_NNZ__TO__RSB_REAL_T"))>1) %!test %! s=sparsersb([1]); %! assert(str2num(sparsersb(1*s,"get","RSB_MIF_MATRIX_TYPECODE__TO__RSB_TYPE_T"))==68) # D %!test %! s=sparsersb([1]); %! assert(str2num(sparsersb(i*s,"get","RSB_MIF_MATRIX_TYPECODE__TO__RSB_TYPE_T"))==90) # Z %!test %! s=sparsersb([1,1],[1,1],[11,21],2,2,"unique"); %! assert(str2num(sparsersb(s,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T"))>0) %!test %! s=sparsersb([1]); %! v=1; %! assert(strfind(sparsersb(sparsersb([1]),"get","WRONG SPEC STRING"),"Error")==1) %!test %! assert(sparsersb(sparsersb([11,0;21,22]),"get","RSB_MIF_TOTAL_SIZE__TO__SIZE_T")>1) %!test %! assert(length(sparsersb(sparsersb([11,0;21,22]),"RSB_MIF_TOTAL_SIZE__TO__SIZE_T"))>1) %!test %! s=sparsersb([11,0;21,22]); %! assert(sparsersb(s,"RSB_MIF_TOTAL_SIZE__TO__SIZE_T") == sparsersb(s,"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")) %!test %! s=sparsersb([1]); %! sparsersb(sparsersb([11,0;21,22]),"save","sparsersb_temporary_matrix_file.mtx") %!test %! [S, NROWS, NCOLS, NNZ, REPINFO, FIELD, SYMMETRY] = sparsersb("sparsersb_temporary_matrix_file.mtx" ); %! assert(NROWS==2) %! assert(NCOLS==2) %! assert(NNZ==3) %! assert(FIELD=="real"); %! assert(SYMMETRY=='U'); %!test %! [S, NROWS, NCOLS, NNZ, REPINFO, FIELD, SYMMETRY] = sparsersb("sparsersb_temporary_matrix_file.mtx", "Z"); %! assert(NROWS==2); %! assert(NCOLS==2); %! assert(NNZ==3); %! assert(FIELD=="complex"); %! assert(SYMMETRY=='U'); %!test %! [S, NROWS, NCOLS, NNZ, REPINFO, FIELD] = sparsersb("sparsersb_temporary_matrix_file.mtx", "D"); %! assert(NROWS==2); %! assert(NCOLS==2); %! assert(NNZ==3); %! assert(FIELD=="real"); %!test %! [S, NROWS, NCOLS, NNZ, REPINFO] = sparsersb("sparsersb_temporary_matrix_file.mtx", "D"); %! assert(NROWS==2); %! assert(NCOLS==2); %! assert(NNZ==3); %!test %! [S, NROWS, NCOLS] = sparsersb("sparsersb_temporary_matrix_file.mtx", "D"); %! assert(NROWS==2); %! assert(NCOLS==2); %!test %! [S, NROWS] = sparsersb("sparsersb_temporary_matrix_file.mtx", "D"); %! assert(NROWS==2); %!test %! rrm=sparsersb(sprand(1000,1000,0.001)); %! sparsersb(rrm,"render", "sparsersb_temporary_render.eps" ,1024); # will use defaults for rWidth %!test %! rrm=sparsersb(sprand(1000,1000,0.001)); %! sparsersb(rrm,"render", "sparsersb_temporary_render.eps" ,1024,1024); %! # sparsersb(rrm,"renderb", "sparsersb_temporary_renderb.eps"); sparsersb(rrm,"renders", "sparsersb_temporary_renders.eps"); # FIXME %!test %! a=sparsersb(sprand(100,100,0.4)); %! sparsersb(a,"autotune"); %!test %! a=sparsersb(sprand(100,100,0.4)); %! o=sparsersb(a,"AUTOTUNE"); %! v=0; %! try %! assert(o==a) %! v=1 %! end_try_catch %! assert(v==0) %! assert(length(o)>10) %!test %! a=sparsersb(sprand(100,100,0.4)); %! o=sparsersb(a,"autotune"); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=2; %! o=sparsersb(a,"autotune","n",nrhs); %! assert(o==a) %!test %! a=1*sparsersb(sprand(100,100,0.4)); %! nrhs=2; %! o=sparsersb(a,"autotune","c",nrhs); %! assert(o==a) %!test %! a=i*sparsersb(sprand(100,100,0.4)); %! nrhs=2; %! o=sparsersb(a,"autotune","c",nrhs); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=1; %! maxr=1; %! o=sparsersb(a,"autotune","N",nrhs,maxr); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=1; %! maxr=1; %! tmax=1; %! o=sparsersb(a,"autotune","n",nrhs,maxr,tmax); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=1; %! maxr=1; %! tmax=1; %! tn=1; %! o=sparsersb(a,"autotune","n",nrhs,maxr,tmax,tn); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=1; %! maxr=1; %! tmax=1; %! tn=1; %! sf=1; %! o=sparsersb(a,"autotune","n",nrhs,maxr,tmax,tn,sf); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=1; %! maxr=1; %! tmax=1; %! tn=2; %! sf=1; %! if getenv ("OMP_NUM_THREADS") != "1" ; %! o=sparsersb(a,"autotune","n",nrhs,maxr,tmax,tn,sf); %! assert(o==a) %! end %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=20; %! maxr=1; %! tmax=1; %! tn=1; %! o=sparsersb(a,"autotune","t",nrhs,maxr,tmax,tn); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=20; %! maxr=1; %! tmax=1; %! tn=1; %! sf=1; %! o=sparsersb(a,"autotune","n",nrhs,maxr,tmax,tn,sf); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=20; %! maxr=1; %! tmax=1; %! tn=0; %! sf=1; %! o=sparsersb(a,"autotune","n",nrhs,maxr,tmax,tn,sf); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=20; %! maxr=0; %! tmax=0; %! tn=0; %! sf=1; %! o=sparsersb(a,"autotune","n",nrhs,maxr,tmax,tn,sf); %! assert(o==a) %!test %! a=sparsersb(sprand(100,100,0.4)); %! nrhs=1; %! maxr=0; %! tmax=0; %! tn=0; %! sf=1; %! wvt=0; %! try %! o=sparsersb(a,"autotune","?",nrhs,maxr,tmax,tn,sf); %! wvt=1; %! end_try_catch %! assert(wvt==0) %! # assert(o==a) # o undefined %!test %! assert( nnz(sparse((toeplitz(sparsersb([0,1,2,3]))-toeplitz(sparse([0,1,2,3])))))==0 ); %!test %! assert( prod(sparsersb([11,12,13;21,22,23])(:) - [11,21,12,22,13,23]')==0); %!test %! A = sprand(4,4,.5); %! assert(prod(reshape(sparsersb(A),[8,2]) - reshape(sparse(A),[8,2]))==0); %!test %! assert(sparsersb([-1,1,2])() == sparsersb([-1,1,2])); %!test %! % symmetry expansion %! A=sparsersb([1+i,0,1;0,1,0;1,0,1]); %! assert(nnz(A)==4 && nnz(full(A))==5); %!test %! % 1-D indexing access is meant to be like in sparse %! A=sparsersb([1+i,0,1;0,1,0;1,0,1]); %! assert(A(1)==(1+i) && A(3)==1 && sparse(A)(3)==1) %! A=sparsersb([1+i,0,1;0,1,0;1,0,1]); %! assert(A(1)==(1+i) && A(2)==0 && sparse(A)(2)==0) %!test %! A=sparsersb([1+i,0,1;0,1,0;1,0,1]); %! assert(0==A(2:5)-sparsersb([1,1],[2,4],[1+0i,1+0i],1,4)) %!test %! assert( nnz(sparse([2,1;1,2])) == 4 && nnz(sparsersb([2,1;1,2])) == 3 ) # symmetry %! assert( nnz(sparse([2,0;1,2])) == 3 && nnz(sparsersb([2,0;1,2])) == 3 ) # no symmetry %!test %! assert( (sparse([2,0;1,2]) \ [1;1]) == (sparsersb([2,0;1,2]) \ [1;1]) ) %! assert( (sparse([2,0;0,2]) \ [1;1]) == (sparsersb([2,0;0,2]) \ [1;1]) ) %!test %! assert( (sparse([2,0;1,2]) * [1;1]) == (sparsersb([2,0;1,2]) * [1;1]) ) %! assert( (sparse([2,0;0,2]) * [1;1]) == (sparsersb([2,0;0,2]) * [1;1]) ) %!test %! % no symmetry expansion and no conversion: %! assert ( ( sparsersb([1,1;1,1])*sparsersb([1,1;1,1] )) == ( sparse([1,0;1,1])*sparse([1,0;1,1]) ) ) %!test %! % symmetry expansion and sparsersb->sparse conversion: %! assert ( ( sparsersb([1,1;1,1])*sparse ([1,1;1,1] )) == ( sparse([1,1;1,1])*sparse([1,1;1,1]) ) ) %!test %! % symmetry expansion and sparsersb->sparse conversion: %! assert ( ( sparse ([1,1;1,1])*sparsersb([1,1;1,1] )) == ( sparse([1,1;1,1])*sparse([1,1;1,1]) ) ) %!test %! % no symmetry expansion and no conversion: %! assert ( ( sparsersb([1,1;1,1])+sparsersb([1,1;1,1] )) == ( sparse([1,0;1,1])+sparse([1,0;1,1]) ) ) %!test %! % symmetry expansion and sparsersb->sparse conversion: %! assert ( ( sparsersb([1,1;1,1])+sparse ([1,1;1,1] )) == ( sparse([1,1;1,1])+sparse([1,1;1,1]) ) ) %!test %! % symmetry expansion and sparsersb->sparse conversion: %! assert ( ( sparse ([1,1;1,1])+sparsersb([1,1;1,1] )) == ( sparse([1,1;1,1])+sparse([1,1;1,1]) ) ) %!test %! % symmetry specification: general %! assert ( sparsersb([1,2,2],[1,1,2],[1,1,1],"general") == sparse([1,0;1,1]) ) %!test %! % symmetry specification: symmetric %! assert ( sparsersb([1,2,2],[1,1,2],[1,1,1],"symmetric") == sparse([1,1;1,1]) ) %!test %! % symmetry specification: symmetric, and conversion and (:,:) access %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"symmetric") == sparse([1,1+i;1+i,1]) ) %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"symmetric") == sparsersb([1,2,2],[1,1,2],[1,1+i,1],"symmetric")(:,:) ) %!test %! % symmetry specification: hermitian, and conversion and (:,:) access %! assert ( sparsersb([1,2,2],[1,1,2],[1,1,1],"hermitian") == sparse([1,1;1,1]) ) %! assert ( sparsersb([1,2,2],[1,1,2],[1,1,1],"hermitian") == sparsersb([1,2,2],[1,1,2],[1,1,1],"hermitian")(:,:) ) %!test %! % symmetry specification: hermitian, and conversion and (:,:) access %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"hermitian") == sparse([1,1-i;1+i,1]) ) %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"hermitian") == sparsersb([1,2,2],[1,1,2],[1,1+i,1],"hermitian")(:,:) ) %!test %! % symmetry or hermitianness: no empty triangle access %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"symmetric")(1,2) == 0 ) %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"hermitian")(1,2) == 0 ) %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"general")(1,2) == 0 ) %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"symmetric")(2,1) != 0 ) %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"hermitian")(2,1) != 0 ) %! assert ( sparsersb([1,2,2],[1,1,2],[1,1+i,1],"general")(2,1) != 0 ) %!test %! % symmetry expansion %! assert ( nnz(sparse(sparsersb([1 ,1;1,1])) - sparse([1 ,1;1,1])) == 0 ) %! assert ( nnz(sparse(sparsersb([1+i,1;1,1])) - sparse([1+i,1;1,1])) == 0 ) %! % hermitianness expansion %! assert ( nnz(sparsersb([1,1+i;1-i,1]) - sparse([1,1+i;1-i,1])) == 0 ) %! % no symmetric complex expansion %! assert ( nnz(sparsersb([1,1+i;1+i,1]) - sparse([1,1+i;1-i,1])) == 1 ) %!test %! assert( (sparse([2, 0; 1, 2])(:,:)) == (sparsersb([2, 0; 1, 2])(:,:)) ) %! assert( (sparse([2, 0; i, 2])(:,:)) == (sparsersb([2, 0; i, 2])(:,:)) ) %!test %! assert( (sparse([2, 0; 1, 2])(2,:)) == (sparsersb([2, 0; 1, 2])(2,:)) ) %! assert( (sparse([2, 0; i, 2])(2,:)) == (sparsersb([2, 0; i, 2])(2,:)) ) %!test %! assert( (sparse([2, 0; 1, 2])(:,2)) == (sparsersb([2, 0; 1, 2])(:,2)) ) %! assert( (sparse([2, 0; i, 2])(:,2)) == (sparsersb([2, 0; i, 2])(:,2)) ) %!test %! assert( (sparse([2,0;1,2]) * [1;1]) == (sparsersb([2,0;1,2]) * [1;1]) ) %! assert( (sparse([2,0;0,2]) * [1;1]) == (sparsersb([2,0;0,2]) * [1;1]) ) %!test %! assert( (sparse([2,0;1,2]) * [i;1]) == (sparsersb([2,0;1,2]) * [i;1]) ) %! assert( (sparse([2,0;0,2]) * [i;1]) == (sparsersb([2,0;0,2]) * [i;1]) ) %!test %! assert( (sparse([2,0;1,2])'* [1;1]) == (sparsersb([2,0;1,2])'* [1;1]) ) %! assert( (sparse([2,0;0,2])'* [1;1]) == (sparsersb([2,0;0,2])'* [1;1]) ) %!test %! assert( (sparse([2,0;1,2])'* [i;1]) == (sparsersb([2,0;1,2])'* [i;1]) ) %! assert( (sparse([2,0;0,2])'* [i;1]) == (sparsersb([2,0;0,2])'* [i;1]) ) %!test %! assert( (sparse([2,0;1,2]).'* [1;1]) == (sparsersb([2,0;1,2]).'* [1;1]) ) %! assert( (sparse([2,0;0,2]).'* [1;1]) == (sparsersb([2,0;0,2]).'* [1;1]) ) %!test %! assert( (sparse([2,0;1,2]).'* [i;1]) == (sparsersb([2,0;1,2]).'* [i;1]) ) %! assert( (sparse([2,0;0,2]).'* [i;1]) == (sparsersb([2,0;0,2]).'* [i;1]) ) %!test %! assert( (sparse([2,0;1,2]) * 1 ) == (sparsersb([2,0;1,2]) * 1 ) ) %! assert( (sparse([2,0;0,2]) * 1 ) == (sparsersb([2,0;0,2]) * 1 ) ) %!test %! assert( (sparse([2,0;1,2]) * i ) == (sparsersb([2,0;1,2]) * i ) ) %! assert( (sparse([2,0;0,2]) * i ) == (sparsersb([2,0;0,2]) * i ) ) %!test %! assert( (sparse([2,0;1,2]).* 1 ) == (sparsersb([2,0;1,2]).* 1 ) ) %! assert( (sparse([2,0;0,2]).* 1 ) == (sparsersb([2,0;0,2]).* 1 ) ) %!test %! assert( (sparse([2,0;1,2]).* i ) == (sparsersb([2,0;1,2]).* i ) ) %! assert( (sparse([2,0;0,2]).* i ) == (sparsersb([2,0;0,2]).* i ) ) %!test %! assert( ( sparse([2,0;1,2]) + 1*sparse([2,0;1,2]) ) == (sparsersb([2,0;1,2]) + 1*sparsersb([2,0;1,2]) ) ) %!test %! assert( ( sparse([2,0;0,2]) + 1*sparse([2,0;0,2]) ) == (sparsersb([2,0;0,2]) + 1*sparsersb([2,0;0,2]) ) ) %!test %! assert( ( sparse([2,0;1,2]) + i*sparse([2,0;1,2]) ) == (sparsersb([2,0;1,2]) + i*sparsersb([2,0;1,2]) ) ) %!test %! assert( ( sparse([2,0;0,2]) + i*sparse([2,0;0,2]) ) == (sparsersb([2,0;0,2]) + i*sparsersb([2,0;0,2]) ) ) %!test %! assert( (sparse([ 1 + 1i,0;0, 1 + 1i]).'* [1,2;1,2]) == (sparsersb([ 1 + 1i,0;0, 1 + 1i]).'* [1,2;1,2]) ) */ /* GENERATED TEST LINES BEGIN */ /* %% tests for a 1 x 1 matrix, density 10%, real %!test %! A = [0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (reshape (sparsersb (A), 1, 1) == reshape (sparse (A), 1, 1)); %% tests for a 1 x 1 matrix, density 10%, complex %!test %! A = [0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (reshape (sparsersb (A), 1, 1) == reshape (sparse (A), 1, 1)); %% tests for a 1 x 3 matrix, density 10%, real %!test %! A = [0,0,0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,0,0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,0,0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,0,0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,0,0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,0,0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,0,0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,0,0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,0,0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,0,0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,3) == sparse (A)(1,3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,0,0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,0,0,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 1 x 3 matrix, density 10%, complex %!test %! A = [0,0,0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,0,0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,0,0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,0,0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,0,0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,0,0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,0,0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,0,0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,0,0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,0,0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,3) == sparse (A)(1,3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,0,0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,0,0,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 1 matrix, density 10%, real %!test %! A = [0,;0,;0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3,1) == sparse (A)(3,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,;0,;0,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 1 matrix, density 10%, complex %!test %! A = [0,;0,;0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3,1) == sparse (A)(3,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,;0,;0,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 3 matrix, density 10%, real %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)(3,3) == sparse (A)(3,3)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)(9) == sparse (A)(9)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (reshape (sparsersb (A), 1, 9) == reshape (sparse (A), 1, 9)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (reshape (sparsersb (A), 3, 3) == reshape (sparse (A), 3, 3)); %!test %! A = [0,0,0,;0,0,0,;0,3,0,;]; assert (reshape (sparsersb (A), 9, 1) == reshape (sparse (A), 9, 1)); %% tests for a 3 x 3 matrix, density 10%, complex %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)(3,3) == sparse (A)(3,3)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)(9) == sparse (A)(9)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (reshape (sparsersb (A), 1, 9) == reshape (sparse (A), 1, 9)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (reshape (sparsersb (A), 3, 3) == reshape (sparse (A), 3, 3)); %!test %! A = [0,0,0,;0,0,0,;0,0,0,;]; assert (reshape (sparsersb (A), 9, 1) == reshape (sparse (A), 9, 1)); %% tests for a 1 x 1 matrix, density 20%, real %!test %! A = [0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (reshape (sparsersb (A), 1, 1) == reshape (sparse (A), 1, 1)); %% tests for a 1 x 1 matrix, density 20%, complex %!test %! A = [0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (reshape (sparsersb (A), 1, 1) == reshape (sparse (A), 1, 1)); %% tests for a 1 x 3 matrix, density 20%, real %!test %! A = [22,0,0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [22,0,0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [22,0,0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [22,0,0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [22,0,0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [22,0,0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [22,0,0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [22,0,0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [22,0,0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [22,0,0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [22,0,0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [22,0,0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [22,0,0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [22,0,0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [22,0,0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [22,0,0,;]; assert (sparsersb (A)(1,3) == sparse (A)(1,3)); %!test %! A = [22,0,0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [22,0,0,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [22,0,0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [22,0,0,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [22,0,0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [22,0,0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [22,0,0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [22,0,0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [22,0,0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [22,0,0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [22,0,0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [22,0,0,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [22,0,0,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 1 x 3 matrix, density 20%, complex %!test %! A = [0,0,0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,0,0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,0,0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,0,0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,0,0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,0,0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,0,0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,0,0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,0,0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,0,0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,3) == sparse (A)(1,3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,0,0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,0,0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,0,0,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 1 matrix, density 20%, real %!test %! A = [0,;0,;68,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)(3,1) == sparse (A)(3,1)); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;68,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;68,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,;0,;68,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 1 matrix, density 20%, complex %!test %! A = [0,;0,;0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3,1) == sparse (A)(3,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;0,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,;0,;0,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 3 matrix, density 20%, real %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)(3,3) == sparse (A)(3,3)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)(9) == sparse (A)(9)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (reshape (sparsersb (A), 1, 9) == reshape (sparse (A), 1, 9)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (reshape (sparsersb (A), 3, 3) == reshape (sparse (A), 3, 3)); %!test %! A = [0,0,0,;3,0,0,;0,0,42,;]; assert (reshape (sparsersb (A), 9, 1) == reshape (sparse (A), 9, 1)); %% tests for a 3 x 3 matrix, density 20%, complex %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)(3,3) == sparse (A)(3,3)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)(9) == sparse (A)(9)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (reshape (sparsersb (A), 1, 9) == reshape (sparse (A), 1, 9)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (reshape (sparsersb (A), 3, 3) == reshape (sparse (A), 3, 3)); %!test %! A = [0+20*i,0,0,;51,0,0,;0,0,0,;]; assert (reshape (sparsersb (A), 9, 1) == reshape (sparse (A), 9, 1)); %% tests for a 1 x 1 matrix, density 50%, real %!test %! A = [54,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [54,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [54,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [54,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [54,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [54,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [54,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [54,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [54,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [54,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [54,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [54,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [54,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [54,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [54,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [54,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [54,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [54,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [54,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [54,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [54,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [54,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [54,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [54,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [54,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [54,;]; assert (reshape (sparsersb (A), 1, 1) == reshape (sparse (A), 1, 1)); %% tests for a 1 x 1 matrix, density 50%, complex %!test %! A = [0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;]; assert (reshape (sparsersb (A), 1, 1) == reshape (sparse (A), 1, 1)); %% tests for a 1 x 3 matrix, density 50%, real %!test %! A = [81,0,1,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [81,0,1,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [81,0,1,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [81,0,1,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [81,0,1,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [81,0,1,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [81,0,1,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [81,0,1,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [81,0,1,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [81,0,1,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [81,0,1,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [81,0,1,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [81,0,1,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [81,0,1,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [81,0,1,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [81,0,1,;]; assert (sparsersb (A)(1,3) == sparse (A)(1,3)); %!test %! A = [81,0,1,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [81,0,1,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [81,0,1,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [81,0,1,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [81,0,1,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [81,0,1,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [81,0,1,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [81,0,1,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [81,0,1,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [81,0,1,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [81,0,1,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [81,0,1,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [81,0,1,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 1 x 3 matrix, density 50%, complex %!test %! A = [0,0+16*i,70,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)(1,3) == sparse (A)(1,3)); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,0+16*i,70,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,0+16*i,70,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,0+16*i,70,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 1 matrix, density 50%, real %!test %! A = [0,;10,;9,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)(3,1) == sparse (A)(3,1)); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;10,;9,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;10,;9,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,;10,;9,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 1 matrix, density 50%, complex %!test %! A = [0,;0,;60+73*i,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)(3,1) == sparse (A)(3,1)); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0,;0,;60+73*i,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0,;0,;60+73*i,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0,;0,;60+73*i,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 3 matrix, density 50%, real %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)(3,3) == sparse (A)(3,3)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)(9) == sparse (A)(9)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (reshape (sparsersb (A), 1, 9) == reshape (sparse (A), 1, 9)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (reshape (sparsersb (A), 3, 3) == reshape (sparse (A), 3, 3)); %!test %! A = [58,0,70,;5,62,0,;0,0,86,;]; assert (reshape (sparsersb (A), 9, 1) == reshape (sparse (A), 9, 1)); %% tests for a 3 x 3 matrix, density 50%, complex %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)(3,3) == sparse (A)(3,3)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)(9) == sparse (A)(9)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (reshape (sparsersb (A), 1, 9) == reshape (sparse (A), 1, 9)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (reshape (sparsersb (A), 3, 3) == reshape (sparse (A), 3, 3)); %!test %! A = [0+64*i,23+36*i,0,;0,0,0,;8,0,0,;]; assert (reshape (sparsersb (A), 9, 1) == reshape (sparse (A), 9, 1)); %% tests for a 1 x 1 matrix, density 100%, real %!test %! A = [21,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [21,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [21,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [21,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [21,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [21,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [21,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [21,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [21,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [21,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [21,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [21,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [21,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [21,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [21,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [21,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [21,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [21,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [21,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [21,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [21,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [21,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [21,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [21,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [21,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [21,;]; assert (reshape (sparsersb (A), 1, 1) == reshape (sparse (A), 1, 1)); %% tests for a 1 x 1 matrix, density 100%, complex %!test %! A = [94+61*i,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [94+61*i,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [94+61*i,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [94+61*i,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [94+61*i,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [94+61*i,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [94+61*i,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [94+61*i,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [94+61*i,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [94+61*i,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [94+61*i,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [94+61*i,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [94+61*i,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [94+61*i,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [94+61*i,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [94+61*i,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [94+61*i,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [94+61*i,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [94+61*i,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [94+61*i,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [94+61*i,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [94+61*i,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [94+61*i,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [94+61*i,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [94+61*i,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [94+61*i,;]; assert (reshape (sparsersb (A), 1, 1) == reshape (sparse (A), 1, 1)); %% tests for a 1 x 3 matrix, density 100%, real %!test %! A = [38,64,99,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [38,64,99,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [38,64,99,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [38,64,99,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [38,64,99,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [38,64,99,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [38,64,99,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [38,64,99,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [38,64,99,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [38,64,99,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [38,64,99,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [38,64,99,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [38,64,99,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [38,64,99,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [38,64,99,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [38,64,99,;]; assert (sparsersb (A)(1,3) == sparse (A)(1,3)); %!test %! A = [38,64,99,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [38,64,99,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [38,64,99,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [38,64,99,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [38,64,99,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [38,64,99,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [38,64,99,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [38,64,99,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [38,64,99,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [38,64,99,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [38,64,99,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [38,64,99,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [38,64,99,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 1 x 3 matrix, density 100%, complex %!test %! A = [0+32*i,84+27*i,78,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)(1,3) == sparse (A)(1,3)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)(1,:) == sparse (A)(1,:)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0+32*i,84+27*i,78,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0+32*i,84+27*i,78,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 1 matrix, density 100%, real %!test %! A = [31,;40,;66,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)(3,1) == sparse (A)(3,1)); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [31,;40,;66,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [31,;40,;66,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [31,;40,;66,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 1 matrix, density 100%, complex %!test %! A = [0+90*i,;25+58*i,;26,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)(3) == sparse (A)(3)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)(3,1) == sparse (A)(3,1)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)(:,1) == sparse (A)(:,1)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (reshape (sparsersb (A), 1, 3) == reshape (sparse (A), 1, 3)); %!test %! A = [0+90*i,;25+58*i,;26,;]; assert (reshape (sparsersb (A), 3, 1) == reshape (sparse (A), 3, 1)); %% tests for a 3 x 3 matrix, density 100%, real %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)(3,3) == sparse (A)(3,3)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)(9) == sparse (A)(9)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (reshape (sparsersb (A), 1, 9) == reshape (sparse (A), 1, 9)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (reshape (sparsersb (A), 3, 3) == reshape (sparse (A), 3, 3)); %!test %! A = [86,42,100,;1,53,72,;6,97,38,;]; assert (reshape (sparsersb (A), 9, 1) == reshape (sparse (A), 9, 1)); %% tests for a 3 x 3 matrix, density 100%, complex %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert ( (sparsersb (A)) == (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (istril (sparsersb (A)) == istril (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (istriu (sparsersb (A)) == istriu (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (isreal (sparsersb (A)) == isreal (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (iscomplex (sparsersb (A)) == iscomplex (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (issymmetric (sparsersb (A)) == issymmetric (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (ishermitian (sparsersb (A)) == ishermitian (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (nnz (sparsersb (A)) == nnz (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (rows (sparsersb (A)) == rows (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (columns (sparsersb (A)) == columns (sparse (A))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)'*(1*ones(size(A,1))) == sparse (A)'*(1*ones(size(A,1)))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)'*(i*ones(size(A,1))) == sparse (A)'*(i*ones(size(A,1)))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)( ) == sparse (A)( )); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)(1) == sparse (A)(1)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)(1,1) == sparse (A)(1,1)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)(3,3) == sparse (A)(3,3)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)(3,:) == sparse (A)(3,:)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)(9) == sparse (A)(9)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)(:) == sparse (A)(:)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)(:,3) == sparse (A)(:,3)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)(:,:) == sparse (A)(:,:)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)*(1*ones(size(A,2))) == sparse (A)*(1*ones(size(A,2)))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)*(i*ones(size(A,2))) == sparse (A)*(i*ones(size(A,2)))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)*1 == sparse (A)*1); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A)*i == sparse (A)*i); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A).'*(1*ones(size(A,1))) == sparse (A).'*(1*ones(size(A,1)))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (sparsersb (A).'*(i*ones(size(A,1))) == sparse (A).'*(i*ones(size(A,1)))); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (reshape (sparsersb (A), 1, 9) == reshape (sparse (A), 1, 9)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (reshape (sparsersb (A), 3, 3) == reshape (sparse (A), 3, 3)); %!test %! A = [88,95,43,;0+76*i,26+64*i,0,;0+61*i,45+54*i,0+15*i,;]; assert (reshape (sparsersb (A), 9, 1) == reshape (sparse (A), 9, 1)); %% Generated with rand state 42 . */ /* GENERATED TEST LINES END */ /* %% tests for different operators multiplications %!test % REAL/REAL %! A = sprandn(1e3,1e3,1/1e3); Arsb = sparsersb(A); v = randn(1e3,1); %! assert(A*v,Arsb*v,1e-14); %! assert(A.'*v,Arsb.'*v,1e-14); %! assert(A'*v,Arsb'*v,1e-14); %!test % REAL/COMPLEX %! A = sprandn(1e6,1e6,1/1e6); Arsb = sparsersb(A); v = 1i*randn(1e6,1) + randn(1e6,1); %! assert(A*v,Arsb*v,1e-14); %! assert(A.'*v,Arsb.'*v,1e-14); %! assert(A'*v,Arsb'*v,1e-14); %!test % COMPLEX/REAL %! A = 1i*sprandn(1e3,1e3,1/1e3) + sprandn(1e3,1e3,1/1e3); Arsb = sparsersb(A); v = randn(1e3,1); %! assert(A*v,Arsb*v,1e-14); %! assert(A.'*v,Arsb.'*v,1e-14); %! assert(A'*v,Arsb'*v,1e-14); %!test % COMPLEX/COMPLEX %! A = 1i*sprandn(1e3,1e3,1/1e3) + sprandn(1e3,1e3,1/1e3); Arsb = sparsersb(A); v = 1i*randn(1e3,1) + randn(1e3,1); %! assert(A*v,Arsb*v,1e-14); %! assert(A.'*v,Arsb.'*v,1e-14); %! assert(A'*v,Arsb'*v,1e-14); */ /* %!demo %! disp("'sparsersb' behaves pretty like 'sparse':") %! R=(rand(3)>.6) %! A_octave=sparse(R) %! A_librsb=sparsersb(R) %!demo %! disp("The interface of 'sparsersb' is almost like the one of 'sparse'") %! disp("Create a 1x1 matrix:") %! sparsersb([2]) %! disp("Create a 2x1 matrix:") %! sparsersb([1,2],[1,1],[11,21]) %! disp("Create a 2x2 matrix:") %! sparsersb([1,2],[1,1],[11,21],2,2) %! disp("Create a 2x2 lower triangular matrix:") %! sparsersb([1,2,2 ],[1,1,2 ],[11,21, 22],2,2) %!demo %! disp("'sparsersb' has an option to handle duplicates.") %! disp("Create a 2x2 lower triangular matrix (last element summed by default):") %! sparsersb([1,2,2,2],[1,1,2,2],[11,21,11,11],2,2) %! disp("Create a 2x2 lower triangular matrix (last two elements summed explicitly):") %! sparsersb([1,2,2,2],[1,1,2,2],[11,21,11,11],2,2,"sum") %! disp("Create a 2x2 lower triangular matrix (last element ignored, explicitly):") %! sparsersb([1,2,2,2],[1,1,2,2],[11,21,11,11],2,2,"unique") %!demo %! disp("'sparsersb' support symmetric and hermitian matrices:\n") %! disp("2x2 lower tringular:") %! sparsersb([1,2,2 ],[1,1,2 ],[11,21 , 22],2,2,"general") %! disp("2x2 symmetric (only lower triangle stored):") %! sparsersb([1,2,2 ],[1,1,2 ],[11,21 , 22],2,2,"symmetric") %! disp("2x2 hermitian (only lower triangle stored):") %! sparsersb([1,2,2 ],[1,1,2 ],[11,21i, 22],2,2,"hermitian") %!demo %! disp("Any 'sparse' or 'dense' matrix can be converted to 'sparsersb':") %! d=sparsersb( [1,2;3,4] ) %! f=sparsersb( full ([1,2;3,4])) %! s=sparsersb(sparse([1,2;3,4])) %!demo %! disp("'sparsersb' detects symmetry:") %! d=sparsersb( [1,2;2,1] ) %! s=sparsersb(sparse([1,2;2,1])) %!demo %! disp("'sparsersb' detects hermitianness:") %! d=sparsersb( [1,i;-i,1] ) %! s=sparsersb(sparse([1,i;-i,1])) %!demo %! disp("The most important use of 'sparsersb' is for multiplying sparse matrices...\n") %! a=sparsersb( [1,2;3,4] ) %! disp("...by dense matrices or vectors:\n") %! x=[1,2;1,2] %! %! disp("Untransposed sparse matrix-vector multiplication:") %! a*x %! %! disp("Transposed sparse matrix-vector multiplication:") %! a'*x %!demo %! d=sparsersb( [1,2;3,4] ); %! s=sparsersb(sparse([1,2;3,4])); %! %! disp("Many sparse-sparse matrix operators work on 'sparsersb'\n") %! disp("'+' operator:") %! s+d %! disp("'.+' operator:") %! s.+d %! disp("'-' operator:") %! s-d %! disp("'.-' operator:") %! s.-d %! disp("'*' operator:") %! s*d %! disp("'.*' operator:") %! s.*d %! disp("'/' operator:") %! s/d %! disp("'./' operator:") %! s./d %! disp("'\\' operator:") %! s\[1;1] %! disp("And others. Not all operators are native: certain use a conversion; see the printout.\n") %!demo %! o=sparse( [1,2;3,4] ); %! s=sparsersb([1,2;3,4] ); %! %! disp("Most of these operators hide a conversion; see the printout:\n") %! %! s(:,:) %! o(:,:) %! %! s(:,2) %! o(:,2) %! %! s(2,:) %! o(2,:) %! %! s(:) %! o(:) %!demo %! disp("On large matrices 'sparsersb' may be faster than 'sparse' in sparse matrix-vector multiplication.") %! disp("In addition to that, 'sparsersb' has an 'empirical online auto-tuning' functionality.") %! disp("It means you run the autotuning on a specific input, and just after, the multiplication might be faster.") %! disp("See this case with two different right hand sides (NRHS) count.\n") %! M=100000; %! N=100000; %! P=100 / M; %! s=sparse(sprand(M,N,P)); %! %! for NRHSc = {1,7} %! r=sparsersb(s); # repeat tuning from 'vanilla' matrix %! assert(nnz(s)==nnz(r)) %! NRHS=cell2mat(NRHSc); %! %! x=ones(M,NRHS); %! printf("Here, a %.2e x %.2e matrix with %.2e nonzeroes, %d NRHS.\n",M,N,nnz(s),NRHS) %! tic(); %! sc=0; %! while(toc()<3) %! s*x; %! sc=sc+1; %! endwhile %! st=toc()/sc; %! printf("Each multiplication with 'sparse' took %.1es.\n",st); %! %! tic(); %! rc=0; %! while(toc()<3) %! r*x; %! rc=rc+1; %! endwhile %! rt=toc()/rc; %! ut=rt; # untuned time %! printf("Each multiplication with 'sparsersb' took %.3es, this is %.4g%% of the time taken by 'sparse'.\n",rt,100*rt/st); %! %! nsb=str2num(sparsersb(r,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")); %! tic; %! r=sparsersb(r,"autotune","n",NRHS); %! at_t=toc; %! nnb=str2num(sparsersb(r,"get","RSB_MIF_LEAVES_COUNT__TO__RSB_BLK_INDEX_T")); %! printf ("Autotuning for %d NRHS took %.2es (%d -> %d RSB blocks).\n", NRHS, at_t, nsb, nnb); %! tic(); %! rc=0; %! while(toc()<3) %! r*x; %! rc=rc+1; %! endwhile %! rt=toc()/rc; %! printf("After tuning, each 'sparsersb' multiplication took %.3es.\n",rt); %! printf("This is %.4g%% of the time taken by 'sparse' (%.2fx speedup).\n",100*rt/st,st/rt); %! if ut > rt; %! printf ("Autotuning brought a %.2fx speedup over original RSB structure.\n", ut/rt); %! printf ("Time spent in autotuning can be amortized in %.1d iterations.\n", at_t/(ut-rt) ); %! else %! printf ("RSB autotuning brought no further speedup for NRHS=%d.\n",NRHS); %! endif %! disp("") %! endfor %!demo %! disp("'sparsersb' can render sparse matrices into Encapsulated Postscript files showing the RSB blocks layout.") %! rm = sparsersb(sprand(100000,100000,.0001)); %! sparsersb(rm,'render','sptest.eps') %! disp("You can open sptest.eps now.") %%!demo */ sparsersb-1.0.9/src/sparsersbtg.m0000755000000000000000000001243014122214045015155 0ustar 00000000000000#!/usr/bin/octave -q # # Copyright (C) 2011-2020 Michele Martone # # 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 . ## -*- texinfo -*- ## @deftypefn {} {} sparsersbtg () ## @deftypefnx {} {} sparsersbtg (@var{k}) ## @deftypefnx {} {} sparsersbtg (@var{k}, @var{m}) ## Invoked with no arguments, print a script with tests of sparse vs sparsersb. ## Invoked with "r" as @var{k}, will use a random seeding scheme. ## ## If @var{k} is "p" and @var{m} a matrix, it will print it out in a ## manner readable by Octave. ## ## @seealso{sparsersb} ## @end deftypefn ## Author: Michele Martone function ret = sparsersbtg (varargin) ret=""; if nargin == 2 && varargin{1} == ['p'] ret = printmat(varargin{2}); return elseif nargin == 1 && varargin{1} == ['r'] rs = sprintf ( "%d;", full (rand ("state") )); rs = sprintf ("%% Generated with rand state [%s].\n", rs); elseif nargin == 1 rs = "%% Generated with rand state 42 .\n"; rand ("state", 42); # seed parms = varargin{1}; if length (parms) == 3 nrl=parms(1); nri=parms(2); nru=parms(3); ncl=parms(1); nci=parms(2); ncu=parms(3); elseif length (parms) == 6 nrl=parms(1); nri=parms(2); nru=parms(3); ncl=parms(4); nci=parms(5); ncu=parms(6); else # Well, error actually. return; end elseif nargin == 0 rs = "%% Generated with rand state 42 .\n"; rand ("state", 42); # seed #printf ("%s","rand(\"state\",42);\n"); # seed #nrl=1;nri=9;nru=10; #ncl=1;nci=9;ncu=10; nrl=1;nri=2;nru=3; ncl=1;nci=2;ncu=3; end for dp = [10,20,50,100] for nr = nrl:nri:nru for nc = ncl:nci:ncu for wc = 0: 1 tt = ""; lp = ""; lp = "%!"; ti = [lp, "test\n"]; if wc A = round (sprand (nr, nc, dp/200)*100) ; A = round (sprand (nr, nc, dp/200)*100)*i + A; else A = round (sprand (nr, nc, dp/100)*100); end if 0 # repeat twice tl = printmat (A); else # define once in A tl = printmat (A); lp = [lp," A = ",tl,"; "]; tl = "A"; end for f = {"","istril","istriu","isreal","iscomplex","issymmetric","ishermitian","nnz","rows","columns"} exp = [f{:}," (sparsersb (",tl,")) == ",f{:}," (sparse (",tl,"))"]; tt = [tt,ti,lp,"assert (",exp,");\n"]; end nrs = sprintf("%d",nr); ncs = sprintf("%d",nc); nrc = sprintf("%d",nr*nc); for f = unique ({"( )","(:)",sprintf("(%s)",nrc),"(1)","(1,1)","(:,:)",sprintf("(%s,:)",nrs),sprintf("(:,%s)",ncs),sprintf("(%s,%s)",nrs,ncs),"*(1*ones(size(A,2)))","*(i*ones(size(A,2)))","'*(1*ones(size(A,1)))","'*(i*ones(size(A,1)))",".'*(1*ones(size(A,1)))",".'*(i*ones(size(A,1)))","*1","*i"}) exp = [ "sparsersb (",tl,")",f{:}," == sparse (",tl,")",f{:}]; tt = [tt,ti,lp,"assert (",exp,");\n"]; end for inr = unique ([1,nr,nr*nc]) inc = (nr * nc) / inr; ra = sprintf (" %d, %d", inr, inc); exp = [ "reshape (sparsersb (",tl,"),",ra,")"," == reshape (sparse (",tl,"),",ra,")"]; tt = [tt,ti,lp,"assert (",exp,");\n"]; end ret = [ret, sprintf("\n%%%% tests for a %g x %g matrix, density %g%%",nr,nc,dp) ]; if wc ; ret = [ret, sprintf(", complex\n") ]; else; ret = [ret , sprintf(", real\n") ] ; end #printf ("%s",tt); ret = [ret, tt]; end end end end ret = [ ret, rs ]; end function s = printrow (v) assert ( rows (v) >= 1); assert (columns (v) >= 1); s = ""; for i = 1 : columns (v) e = v(1,i); if iscomplex (v(1,i)) s = sprintf ("%s%g+%g*i,", s, real (e), imag (e)); else s = sprintf ("%s%g,", s, e); end end s = sprintf ("%s;", s); #s = sprintf("%s;", sprintf ("%g,", full(v(1,:)))); # only real end function s = printmat(v) assert ( rows (v) >= 1); assert (columns (v) >= 1); s = ""; v = full (v); for i = 1:rows (v) s = sprintf ("%s%s", s, printrow(v(i,:))); end s = sprintf ("[%s]", s); end %!test %! sparsersbtg ('p', [1]); %! assert ( strcmp (sparsersbtg ('p', [1]) , ["[1,;]"])) %!test %! sparsersbtg ('p', [1,1,2,2]); %! assert ( strcmp (sparsersbtg ('p', [1,1,2,2]), ["[1,1,2,2,;]"])) %!test %! sparsersbtg ('p', [1,1;2,2]); %! assert ( strcmp (sparsersbtg ('p', [1,1;2,2]), ["[1,1,;2,2,;]"])) %!test %! sparsersbtg ('p', [1+i]); %! assert ( strcmp (sparsersbtg ('p', [1+i]) , ["[1+1*i,;]"])) %!test %! sparsersbtg ('p', [1+i,1,2+i,2]); %! assert ( strcmp (sparsersbtg ('p', [1+i,1,2+i,2]), ["[1+1*i,1,2+1*i,2,;]"])) %!test %! sparsersbtg ('p', [1+i,1;2+i,2]); %! assert ( strcmp (sparsersbtg ('p', [1+i,1;2+i,2]), ["[1+1*i,1,;2+1*i,2,;]"])) %!test %! assert( length( sparsersbtg () ) >= 57846 ) %! assert( length( sparsersbtg ([1,1,1,1,1,1]) ) >= 11218 ) %! assert( length( sparsersbtg ([1,1,1]) ) >= 11218 ) %! assert( length( sparsersbtg ([1]) ) == 0 ) sparsersb-1.0.9/src/srut.awk0000644000000000000000000000200714122214045014135 0ustar 00000000000000#!/usr/bin/awk -f # # Copyright (C) 2011-2020 Michele Martone # # 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 . # sparsersb update tests # awk -f srut.awk < sparsersb.cc > sparsersb.cc.new BEGIN { wp=1; of=""; } /GENERATED TEST LINES BEGIN/ { wp=0; print; system("octave --eval 'printf(\"%s\",sparsersbtg ())'") ; } /GENERATED TEST LINES END/ { wp=1; } /.*/ { if(wp==1) print; } sparsersb-1.0.9/src/configure0000755000175000017500000041157314121051133014353 0ustar dezdez#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.72a.18-fbdf for octave sparsersb package 1.0.9. # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, # Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as 'sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed 'exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="as_nop=: if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else \$as_nop case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ) then : else \$as_nop exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 blah=\$(echo \$(echo blah)) test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" if (eval "$as_required") 2>/dev/null then : as_have_required=yes else $as_nop as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null then : else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$as_shell as_have_required=yes if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null then : break 2 fi fi done;; esac as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop if { test -f "$SHELL" || test -f "$SHELL.exe"; } && as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$SHELL as_have_required=yes fi fi if test "x$CONFIG_SHELL" != x then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed 'exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno then : printf "%s\n" "$0: This script requires a shell more modern than all" printf "%s\n" "$0: the shells that I found on your system." if test ${ZSH_VERSION+y} ; then printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable. # In both cases, we have to default to 'cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='octave sparsersb package' PACKAGE_TARNAME='octave-sparsersb-package' PACKAGE_VERSION='1.0.9' PACKAGE_STRING='octave sparsersb package 1.0.9' PACKAGE_BUGREPORT='' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_STDIO_H # include #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_header_cxx_list= ac_subst_vars='LTLIBOBJS LIBOBJS TARGETS HAVE_OCTAVE_VALUE_ISCOMPLEX HAVE_LIBRSB_CONFIG LIBRSB_TARBALL SPARSERSB_CXX11 SPARSERSB_CXXFLAGS SPARSERSB_LDFLAGS MKOCTFILE OCTAVE OBJEXT EXEEXT ac_ct_CXX CPPFLAGS LDFLAGS CXXFLAGS CXX target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_static_librsb with_librsb_tarball with_librsb_conf ' ac_precious_vars='build_alias host_alias target_alias CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC MKOCTFILE OCTAVE SPARSERSB_LDFLAGS SPARSERSB_CXXFLAGS SPARSERSB_CXX11 LIBRSB_TARBALL' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: '$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: '$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: '$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: '$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: '$ac_option' Try '$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: '$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: '$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but 'cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF 'configure' configures octave sparsersb package 1.0.9 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print 'checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for '--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or '..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, 'make install' will install all the files in '$ac_default_prefix/bin', '$ac_default_prefix/lib' etc. You can specify an installation prefix other than '$ac_default_prefix' using '--prefix', for instance '--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/octave-sparsersb-package] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of octave sparsersb package 1.0.9:";; esac cat <<\_ACEOF Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-static-librsb=yes|no Whether to use static linking with the librsb-conf script. (recommended: yes). --with-librsb-tarball=... Will use specified user provided librsb tarball (e.g. librsb-1.2.0.tar.gz) to build a local librsb installation. You can specify LIBRSB_CFLAGS to customize. With this option --with-librsb-conf will be ignored. --with-librsb-conf=... Path to the librsb-config program (or its directory) which will be used to recover SPARSERSB_CXXFLAGS and SPARSERSB_LDFLAGS (unless specified explicitly). Some influential environment variables: CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory MKOCTFILE The mkoctfile executable OCTAVE The octave executable SPARSERSB_LDFLAGS Linking flags for sparsersb SPARSERSB_CXXFLAGS C++ compilation flags for sparsersb SPARSERSB_CXX11 C++11 additional compilation flags for sparsersb LIBRSB_TARBALL Environment variable equivalent for --with-librsb-tarball=.. Use these variables to override the choices made by 'configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for configure.gnu first; this name is used for a wrapper for # Metaconfig's "Configure" on case-insensitive file systems. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF octave sparsersb package configure 1.0.9 generated by GNU Autoconf 2.72a.18-fbdf Copyright (C) 2021 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_cxx_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link ac_configure_args_raw= for ac_arg do case $ac_arg in *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_configure_args_raw " '$ac_arg'" done case $ac_configure_args_raw in *$as_nl*) ac_safe_unquote= ;; *) ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. ac_unsafe_a="$ac_unsafe_z#~" ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; esac cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by octave sparsersb package $as_me 1.0.9, which was generated by GNU Autoconf 2.72a.18-fbdf. Invocation command line was $ $0$ac_configure_args_raw _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac printf "%s\n" "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Sanitize IFS. IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo printf "%s\n" "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo printf "%s\n" "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then printf "%s\n" "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then printf "%s\n" "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && printf "%s\n" "$as_me: caught signal $ac_signal" printf "%s\n" "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h printf "%s\n" "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then ac_site_files="$CONFIG_SITE" elif test "x$prefix" != xNONE; then ac_site_files="$prefix/share/config.site $prefix/etc/config.site" else ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi for ac_site_file in $ac_site_files do case $ac_site_file in #( */*) : ;; #( *) : ac_site_file=./$ac_site_file ;; esac if test -f "$ac_site_file" && test -r "$ac_site_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See 'config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 printf "%s\n" "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 printf "%s\n" "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Test code for whether the C++ compiler supports C++98 (global declarations) ac_cxx_conftest_cxx98_globals=' // Does the compiler advertise C++98 conformance? #if !defined __cplusplus || __cplusplus < 199711L # error "Compiler does not advertise C++98 conformance" #endif // These inclusions are to reject old compilers that // lack the unsuffixed header files. #include #include // and are *not* freestanding headers in C++98. extern void assert (int); namespace std { extern int strcmp (const char *, const char *); } // Namespaces, exceptions, and templates were all added after "C++ 2.0". using std::exception; using std::strcmp; namespace { void test_exception_syntax() { try { throw "test"; } catch (const char *s) { // Extra parentheses suppress a warning when building autoconf itself, // due to lint rules shared with more typical C programs. assert (!(strcmp) (s, "test")); } } template struct test_template { T const val; explicit test_template(T t) : val(t) {} template T add(U u) { return static_cast(u) + val; } }; } // anonymous namespace ' # Test code for whether the C++ compiler supports C++98 (body of main) ac_cxx_conftest_cxx98_main=' assert (argc); assert (! argv[0]); { test_exception_syntax (); test_template tt (2.0); assert (tt.add (4) == 6.0); assert (true && !false); } ' # Test code for whether the C++ compiler supports C++11 (global declarations) ac_cxx_conftest_cxx11_globals=' // Does the compiler advertise C++ 2011 conformance? #if !defined __cplusplus || __cplusplus < 201103L # error "Compiler does not advertise C++11 conformance" #endif namespace cxx11test { constexpr int get_val() { return 20; } struct testinit { int i; double d; }; class delegate { public: delegate(int n) : n(n) {} delegate(): delegate(2354) {} virtual int getval() { return this->n; }; protected: int n; }; class overridden : public delegate { public: overridden(int n): delegate(n) {} virtual int getval() override final { return this->n * 2; } }; class nocopy { public: nocopy(int i): i(i) {} nocopy() = default; nocopy(const nocopy&) = delete; nocopy & operator=(const nocopy&) = delete; private: int i; }; // for testing lambda expressions template Ret eval(Fn f, Ret v) { return f(v); } // for testing variadic templates and trailing return types template auto sum(V first) -> V { return first; } template auto sum(V first, Args... rest) -> V { return first + sum(rest...); } } ' # Test code for whether the C++ compiler supports C++11 (body of main) ac_cxx_conftest_cxx11_main=' { // Test auto and decltype auto a1 = 6538; auto a2 = 48573953.4; auto a3 = "String literal"; int total = 0; for (auto i = a3; *i; ++i) { total += *i; } decltype(a2) a4 = 34895.034; } { // Test constexpr short sa[cxx11test::get_val()] = { 0 }; } { // Test initializer lists cxx11test::testinit il = { 4323, 435234.23544 }; } { // Test range-based for int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; for (auto &x : array) { x += 23; } } { // Test lambda expressions using cxx11test::eval; assert (eval ([](int x) { return x*2; }, 21) == 42); double d = 2.0; assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0); assert (d == 5.0); assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0); assert (d == 5.0); } { // Test use of variadic templates using cxx11test::sum; auto a = sum(1); auto b = sum(1, 2); auto c = sum(1.0, 2.0, 3.0); } { // Test constructor delegation cxx11test::delegate d1; cxx11test::delegate d2(); cxx11test::delegate d3(45); } { // Test override and final cxx11test::overridden o1(55464); } { // Test nullptr char *c = nullptr; } { // Test template brackets test_template<::test_template> v(test_template(12)); } { // Unicode literals char const *utf8 = u8"UTF-8 string \u2500"; char16_t const *utf16 = u"UTF-8 string \u2500"; char32_t const *utf32 = U"UTF-32 string \u2500"; } ' # Test code for whether the C compiler supports C++11 (complete). ac_cxx_conftest_cxx11_program="${ac_cxx_conftest_cxx98_globals} ${ac_cxx_conftest_cxx11_globals} int main (int argc, char **argv) { int ok = 0; ${ac_cxx_conftest_cxx98_main} ${ac_cxx_conftest_cxx11_main} return ok; } " # Test code for whether the C compiler supports C++98 (complete). ac_cxx_conftest_cxx98_program="${ac_cxx_conftest_cxx98_globals} int main (int argc, char **argv) { int ok = 0; ${ac_cxx_conftest_cxx98_main} return ok; } " as_fn_append ac_header_cxx_list " stdio.h stdio_h HAVE_STDIO_H" as_fn_append ac_header_cxx_list " stdlib.h stdlib_h HAVE_STDLIB_H" as_fn_append ac_header_cxx_list " string.h string_h HAVE_STRING_H" as_fn_append ac_header_cxx_list " inttypes.h inttypes_h HAVE_INTTYPES_H" as_fn_append ac_header_cxx_list " stdint.h stdint_h HAVE_STDINT_H" as_fn_append ac_header_cxx_list " strings.h strings_h HAVE_STRINGS_H" as_fn_append ac_header_cxx_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" as_fn_append ac_header_cxx_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_cxx_list " unistd.h unistd_h HAVE_UNISTD_H" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' was set to '$ac_old_val' in the previous run" >&5 printf "%s\n" "$as_me: error: '$ac_var' was set to '$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' was not set in the previous run" >&5 printf "%s\n" "$as_me: error: '$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' has changed since the previous run:" >&5 printf "%s\n" "$as_me: error: '$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in '$ac_var' since the previous run:" >&5 printf "%s\n" "$as_me: warning: ignoring whitespace changes in '$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: '$ac_old_val'" >&5 printf "%s\n" "$as_me: former value: '$ac_old_val'" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: '$ac_new_val'" >&5 printf "%s\n" "$as_me: current value: '$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run '${MAKE-make} distclean' and/or 'rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Checks for programs. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CXX+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 printf "%s\n" "$CXX" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CXX+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 printf "%s\n" "$ac_ct_CXX" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 printf %s "checking whether the C++ compiler works... " >&6; } ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # Autoconf-2.13 could set the ac_cv_exeext variable to 'no'. # So ignore a value of 'no', otherwise this would lead to 'EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an '-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else $as_nop ac_file='' fi if test -z "$ac_file" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables See 'config.log' for more details" "$LINENO" 5; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 printf %s "checking for C++ compiler default output file name... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 printf "%s\n" "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 printf %s "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # If both 'conftest.exe' and 'conftest' are 'present' (well, observable) # catch 'conftest.exe'. For instance with Cygwin, 'ls conftest' will # work properly (i.e., refer to 'conftest.exe'), while it won't with # 'rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else $as_nop { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See 'config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 printf "%s\n" "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 printf %s "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error 77 "cannot run C++ compiled programs. If you meant to cross compile, use '--host'. See 'config.log' for more details" "$LINENO" 5; } fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 printf "%s\n" "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 printf %s "checking for suffix of object files... " >&6; } if test ${ac_cv_objext+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See 'config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 printf "%s\n" "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C++" >&5 printf %s "checking whether the compiler supports GNU C++... " >&6; } if test ${ac_cv_cxx_compiler_gnu+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO" then : ac_compiler_gnu=yes else $as_nop ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 printf "%s\n" "$ac_cv_cxx_compiler_gnu" >&6; } ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+y} ac_save_CXXFLAGS=$CXXFLAGS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 printf %s "checking whether $CXX accepts -g... " >&6; } if test ${ac_cv_prog_cxx_g+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO" then : ac_cv_prog_cxx_g=yes else $as_nop CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO" then : else $as_nop ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO" then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 printf "%s\n" "$ac_cv_prog_cxx_g" >&6; } if test $ac_test_CXXFLAGS; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_prog_cxx_stdcxx=no if test x$ac_prog_cxx_stdcxx = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 printf %s "checking for $CXX option to enable C++11 features... " >&6; } if test ${ac_cv_prog_cxx_cxx11+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cxx_cxx11=no ac_save_CXX=$CXX cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_cxx_conftest_cxx11_program _ACEOF for ac_arg in '' -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x -qlanglvl=extended0x -AA do CXX="$ac_save_CXX $ac_arg" if ac_fn_cxx_try_compile "$LINENO" then : ac_cv_prog_cxx_cxx11=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cxx_cxx11" != "xno" && break done rm -f conftest.$ac_ext CXX=$ac_save_CXX fi if test "x$ac_cv_prog_cxx_cxx11" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cxx_cxx11" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5 printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; } CXX="$CXX $ac_cv_prog_cxx_cxx11" fi ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11 ac_prog_cxx_stdcxx=cxx11 fi fi if test x$ac_prog_cxx_stdcxx = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 printf %s "checking for $CXX option to enable C++98 features... " >&6; } if test ${ac_cv_prog_cxx_cxx98+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cxx_cxx98=no ac_save_CXX=$CXX cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_cxx_conftest_cxx98_program _ACEOF for ac_arg in '' -std=gnu++98 -std=c++98 -qlanglvl=extended -AA do CXX="$ac_save_CXX $ac_arg" if ac_fn_cxx_try_compile "$LINENO" then : ac_cv_prog_cxx_cxx98=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cxx_cxx98" != "xno" && break done rm -f conftest.$ac_ext CXX=$ac_save_CXX fi if test "x$ac_cv_prog_cxx_cxx98" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cxx_cxx98" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5 printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; } CXX="$CXX $ac_cv_prog_cxx_cxx98" fi ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98 ac_prog_cxx_stdcxx=cxx98 fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}octave", so it can be a program name with args. set dummy ${ac_tool_prefix}octave; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_OCTAVE+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$OCTAVE"; then ac_cv_prog_OCTAVE="$OCTAVE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OCTAVE="${ac_tool_prefix}octave" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCTAVE=$ac_cv_prog_OCTAVE if test -n "$OCTAVE"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OCTAVE" >&5 printf "%s\n" "$OCTAVE" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_OCTAVE"; then ac_ct_OCTAVE=$OCTAVE # Extract the first word of "octave", so it can be a program name with args. set dummy octave; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_OCTAVE+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_OCTAVE"; then ac_cv_prog_ac_ct_OCTAVE="$ac_ct_OCTAVE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCTAVE="octave" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCTAVE=$ac_cv_prog_ac_ct_OCTAVE if test -n "$ac_ct_OCTAVE"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCTAVE" >&5 printf "%s\n" "$ac_ct_OCTAVE" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OCTAVE" = x; then OCTAVE="none" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCTAVE=$ac_ct_OCTAVE fi else OCTAVE="$ac_cv_prog_OCTAVE" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mkoctfile", so it can be a program name with args. set dummy ${ac_tool_prefix}mkoctfile; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_MKOCTFILE+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$MKOCTFILE"; then ac_cv_prog_MKOCTFILE="$MKOCTFILE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_MKOCTFILE="${ac_tool_prefix}mkoctfile" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MKOCTFILE=$ac_cv_prog_MKOCTFILE if test -n "$MKOCTFILE"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKOCTFILE" >&5 printf "%s\n" "$MKOCTFILE" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_MKOCTFILE"; then ac_ct_MKOCTFILE=$MKOCTFILE # Extract the first word of "mkoctfile", so it can be a program name with args. set dummy mkoctfile; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_MKOCTFILE+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_MKOCTFILE"; then ac_cv_prog_ac_ct_MKOCTFILE="$ac_ct_MKOCTFILE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MKOCTFILE="mkoctfile" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MKOCTFILE=$ac_cv_prog_ac_ct_MKOCTFILE if test -n "$ac_ct_MKOCTFILE"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MKOCTFILE" >&5 printf "%s\n" "$ac_ct_MKOCTFILE" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_MKOCTFILE" = x; then MKOCTFILE="none" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MKOCTFILE=$ac_ct_MKOCTFILE fi else MKOCTFILE="$ac_cv_prog_MKOCTFILE" fi if test "$MKOCTFILE" = "none" ; then as_fn_error $? "mkoctfile required to install $PACKAGE_NAME" "$LINENO" 5 fi MKOCTFILE="$MKOCTFILE -g" # Checks for librsb have_rsb=no librsb_conf='no' librsb_conf_static='no' # internal # Check whether --with-static-librsb was given. if test ${with_static_librsb+y} then : withval=$with_static_librsb; librsb_conf_static=$withval; if x"$librsb_conf_static" != xyes -a x"$librsb_conf_static" != xno ; then as_fn_error $? "--static-librsb=yes or --static-librsb=no !! " "$LINENO" 5 fi fi # BEGIN tarball-based on-the-fly install of librsb # Check whether --with-librsb-tarball was given. if test ${with_librsb_tarball+y} then : withval=$with_librsb_tarball; librsb_tarball=$withval else $as_nop librsb_tarball=no fi if test x"$LIBRSB_TARBALL" != "x" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Detected user-set LIBRSB_TARBALL=... variable; equivalent to --with-librsb-tarball=... ." >&5 printf "%s\n" "$as_me: Detected user-set LIBRSB_TARBALL=... variable; equivalent to --with-librsb-tarball=... ." >&6;} librsb_tarball="$LIBRSB_TARBALL" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: No user-set LIBRSB_TARBALL environment variable detected (set it to build using a custom librsb tarball)." >&5 printf "%s\n" "$as_me: No user-set LIBRSB_TARBALL environment variable detected (set it to build using a custom librsb tarball)." >&6;} fi if test x"$librsb_tarball" != x"no" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Will create a local librsb build from user provided \"$librsb_tarball\" tarball. Will use default LIBRSB_CFLAGS." >&5 printf "%s\n" "$as_me: Will create a local librsb build from user provided \"$librsb_tarball\" tarball. Will use default LIBRSB_CFLAGS." >&6;} test -f ${librsb_tarball} || as_fn_error $? "Are you sure of having file $librsb_tarball ?" "$LINENO" 5 tar xzf "$librsb_tarball" || as_fn_error $? "Error uncompressing \"$librsb_tarball\" ?" "$LINENO" 5 librsb_dir=`basename $librsb_tarball` librsb_dir=${librsb_dir/.tar.gz/} test -d "$librsb_dir" || as_fn_error $? "Error accessing \"$librsb_dir\" -- are you sure you provided a valid librsb tarball ?" "$LINENO" 5 LIBRSB_PREFIX="`pwd`/local" cd "$librsb_dir" || as_fn_error $? "Error entering \"$librsb_dir\" -- are you sure you provided a valid librsb tarball ?" "$LINENO" 5 # LIBRSB_CFLAGS="${LIBRSB_CFLAGS:--O3 -fPIC}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Stepped in \"$librsb_dir\"." >&5 printf "%s\n" "$as_me: Stepped in \"$librsb_dir\"." >&6;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Configuring with LIBRSB_CFLAGS=$LIBRSB_CFLAGS " >&5 printf "%s\n" "$as_me: Configuring with LIBRSB_CFLAGS=$LIBRSB_CFLAGS " >&6;} ./configure OCTAVE='false' CFLAGS="${LIBRSB_CFLAGS}" --prefix="${LIBRSB_PREFIX}" --disable-fortran-examples --disable-c-examples { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Configured successfully." >&5 printf "%s\n" "$as_me: Configured successfully." >&6;} make || as_fn_error $? "Make step failed !" "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Built successfully." >&5 printf "%s\n" "$as_me: Built successfully." >&6;} make install || as_fn_error $? "Make step failed !" "$LINENO" 5 cd - librsb_conf="${LIBRSB_PREFIX}"/bin/librsb-config test -f ${librsb_conf} || as_fn_error $? "Temporary librsb installation config file ${librsb_conf} not executable ? Something went wrong with the install ?!" "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Temporary librsb installation in ${LIBRSB_PREFIX} done." >&5 printf "%s\n" "$as_me: Temporary librsb installation in ${LIBRSB_PREFIX} done." >&6;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Forcing static linking due to temporary librsb." >&5 printf "%s\n" "$as_me: Forcing static linking due to temporary librsb." >&6;} librsb_conf_static='yes' else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: No librsb tarball provided: following the default procedure." >&5 printf "%s\n" "$as_me: No librsb tarball provided: following the default procedure." >&6;} true; fi # END tarball-based on-the-fly install of librsb if test x"$librsb_conf" = x"no" ; then # Check whether --with-librsb-conf was given. if test ${with_librsb_conf+y} then : withval=$with_librsb_conf; librsb_conf=$withval; else $as_nop librsb_conf=no fi if test x"$librsb_conf" != x"no" ; then if test -d "$librsb_conf" -a -x "$librsb_conf/librsb-config"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Considering user provided ${librsb_conf} config dir." >&5 printf "%s\n" "$as_me: Considering user provided ${librsb_conf} config dir." >&6;} librsb_conf="$librsb_conf/librsb-config"; fi if test '!' -x "$librsb_conf" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Taking absolute path to ${librsb_conf}." >&5 printf "%s\n" "$as_me: Taking absolute path to ${librsb_conf}." >&6;} librsb_conf=`which "$librsb_conf"` fi if test -x "$librsb_conf" ; then true else as_fn_error $? "Executable config file not found with user-provided ${librsb_conf} path!" "$LINENO" 5 fi fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using ${librsb_conf} config file from the local librsb installation." >&5 printf "%s\n" "$as_me: Using ${librsb_conf} config file from the local librsb installation." >&6;} fi if test x"$librsb_conf" != x"no" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using user provided $librsb_conf script for librsb." >&5 printf "%s\n" "$as_me: Using user provided $librsb_conf script for librsb." >&6;} else # Extract the first word of "librsb-config", so it can be a program name with args. set dummy librsb-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_HAVE_LIBRSB_CONFIG+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$HAVE_LIBRSB_CONFIG"; then ac_cv_prog_HAVE_LIBRSB_CONFIG="$HAVE_LIBRSB_CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_HAVE_LIBRSB_CONFIG="yes" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_HAVE_LIBRSB_CONFIG" && ac_cv_prog_HAVE_LIBRSB_CONFIG="no" fi fi HAVE_LIBRSB_CONFIG=$ac_cv_prog_HAVE_LIBRSB_CONFIG if test -n "$HAVE_LIBRSB_CONFIG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $HAVE_LIBRSB_CONFIG" >&5 printf "%s\n" "$HAVE_LIBRSB_CONFIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$HAVE_LIBRSB_CONFIG" != x"no"; then librsb_conf=librsb-config fi fi if test x"$SPARSERSB_CXXFLAGS" != "x" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using user set SPARSERSB_CXXFLAGS..." >&5 printf "%s\n" "$as_me: Using user set SPARSERSB_CXXFLAGS..." >&6;} else if test x"$librsb_conf" != x"no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Setting SPARSERSB_CXXFLAGS from $librsb_conf --I_opts..." >&5 printf "%s\n" "$as_me: Setting SPARSERSB_CXXFLAGS from $librsb_conf --I_opts..." >&6;} SPARSERSB_CXXFLAGS="`$librsb_conf --I_opts`" fi fi OCTAVE_CLI="$OCTAVE --no-gui --no-window-system"; SPARSERSB_USE_64BIT_IDX=`$OCTAVE_CLI --no-line-editing -qf --eval 'printf ("%i", sizemax() > intmax ("int32"))'` if test x"$SPARSERSB_USE_64BIT_IDX" = x"1" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Adding -D RSBOI_DETECTED_LONG_IDX to SPARSERSB_CXXFLAGS ..." >&5 printf "%s\n" "$as_me: Adding -D RSBOI_DETECTED_LONG_IDX to SPARSERSB_CXXFLAGS ..." >&6;} SPARSERSB_CXXFLAGS="$SPARSERSB_CXXFLAGS -D RSBOI_DETECTED_LONG_IDX=1" fi if test x"$SPARSERSB_LDFLAGS" != "x" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using user set SPARSERSB_LDFLAGS..." >&5 printf "%s\n" "$as_me: Using user set SPARSERSB_LDFLAGS..." >&6;} else if test x"$librsb_conf" != x"no"; then if test x"$librsb_conf_static" = x"no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Setting SPARSERSB_LDFLAGS from --L_opts --libs" >&5 printf "%s\n" "$as_me: Setting SPARSERSB_LDFLAGS from --L_opts --libs" >&6;} SPARSERSB_LDFLAGS="`$librsb_conf --L_opts --libs`" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Setting SPARSERSB_LDFLAGS from --static --libs --extra_libs" >&5 printf "%s\n" "$as_me: Setting SPARSERSB_LDFLAGS from --static --libs --extra_libs" >&6;} SPARSERSB_LDFLAGS="`$librsb_conf --static --libs --extra_libs`" fi fi fi if test x"$SPARSERSB_CXXFLAGS" = "x" ; then ac_header= ac_cache= for ac_item in $ac_header_cxx_list do if test $ac_cache; then ac_fn_cxx_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then printf "%s\n" "#define $ac_item 1" >> confdefs.h fi ac_header= ac_cache= elif test $ac_header; then ac_cache=$ac_item else ac_header=$ac_item fi done if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes then : printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h fi for ac_header in rsb.h do : ac_fn_cxx_check_header_compile "$LINENO" "rsb.h" "ac_cv_header_rsb_h" "$ac_includes_default" if test "x$ac_cv_header_rsb_h" = xyes then : printf "%s\n" "#define HAVE_RSB_H 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing rsb_lib_init" >&5 printf %s "checking for library containing rsb_lib_init... " >&6; } if test ${ac_cv_search_rsb_lib_init+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ namespace conftest { extern "C" int rsb_lib_init (); } int main (void) { return conftest::rsb_lib_init (); ; return 0; } _ACEOF for ac_lib in '' rsb do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO" then : ac_cv_search_rsb_lib_init=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_rsb_lib_init+y} then : break fi done if test ${ac_cv_search_rsb_lib_init+y} then : else $as_nop ac_cv_search_rsb_lib_init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_rsb_lib_init" >&5 printf "%s\n" "$ac_cv_search_rsb_lib_init" >&6; } ac_res=$ac_cv_search_rsb_lib_init if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" SPARSERSB_CXXFLAGS=" " fi fi done fi if test x"$SPARSERSB_LDFLAGS" = "x" ; then for ac_header in rsb.h do : ac_fn_cxx_check_header_compile "$LINENO" "rsb.h" "ac_cv_header_rsb_h" "$ac_includes_default" if test "x$ac_cv_header_rsb_h" = xyes then : printf "%s\n" "#define HAVE_RSB_H 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing rsb_lib_init" >&5 printf %s "checking for library containing rsb_lib_init... " >&6; } if test ${ac_cv_search_rsb_lib_init+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ namespace conftest { extern "C" int rsb_lib_init (); } int main (void) { return conftest::rsb_lib_init (); ; return 0; } _ACEOF for ac_lib in '' rsb do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO" then : ac_cv_search_rsb_lib_init=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_rsb_lib_init+y} then : break fi done if test ${ac_cv_search_rsb_lib_init+y} then : else $as_nop ac_cv_search_rsb_lib_init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_rsb_lib_init" >&5 printf "%s\n" "$ac_cv_search_rsb_lib_init" >&6; } ac_res=$ac_cv_search_rsb_lib_init if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" SPARSERSB_LDFLAGS="-lrsb" fi fi done fi if test x"$SPARSERSB_CXXFLAGS" = "x" ; then as_fn_error $? "$PACKAGE_NAME SPARSERSB_CXXFLAGS (librsb not detected)!" "$LINENO" 5 fi if test x"$SPARSERSB_LDFLAGS" = "x" ; then as_fn_error $? "$PACKAGE_NAME requires SPARSERSB_LDFLAGS (librsb not detected)!" "$LINENO" 5 fi have_rsb=yes { printf "%s\n" "$as_me:${as_lineno-$LINENO}: SPARSERSB_CXXFLAGS is $SPARSERSB_CXXFLAGS" >&5 printf "%s\n" "$as_me: SPARSERSB_CXXFLAGS is $SPARSERSB_CXXFLAGS" >&6;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: SPARSERSB_LDFLAGS is $SPARSERSB_LDFLAGS" >&5 printf "%s\n" "$as_me: SPARSERSB_LDFLAGS is $SPARSERSB_LDFLAGS" >&6;} # TODO: alternative: build librsb with SPARSERSB_LIBRSB_TARBALL # TODO: alternative: --with-librsb=tarball will skip all checks and use that tarball if test "$have_rsb" != "yes" ; then as_fn_error $? "$PACKAGE_NAME requires librsb library" "$LINENO" 5 fi # check for octave functions save_CXX="$CXX" save_CXXFLAGS="$CXXFLAGS" CXX=`${MKOCTFILE} -p CXX` CXXFLAGS="$CXXFLAGS -I`$MKOCTFILE -p OCTINCLUDEDIR`" # need to use interpreter->get_load_path in dev version of octave, # prior to that methods of load_path were static { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for octave_value function iscomplex" >&5 printf %s "checking for octave_value function iscomplex... " >&6; } if test ${octave_value_cv_iscomplex+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { octave_value().iscomplex(); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO" then : octave_value_cv_iscomplex=yes else $as_nop octave_value_cv_iscomplex=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $octave_value_cv_iscomplex" >&5 printf "%s\n" "$octave_value_cv_iscomplex" >&6; } if test "$octave_value_cv_iscomplex" = "yes" ; then HAVE_OCTAVE_VALUE_ISCOMPLEX=-DHAVE_OCTAVE_VALUE_ISCOMPLEX else HAVE_OCTAVE_VALUE_ISCOMPLEX= fi CC=$save_CXX CXXFLAGS=$save_CXXFLAGS SPARSERSB_CXX11="-std=gnu++11" ac_config_files="$ac_config_files Makeconf" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # 'ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* 'ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # 'set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # 'set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 printf "%s\n" "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as 'sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable. # In both cases, we have to default to 'cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by octave sparsersb package $as_me 1.0.9, which was generated by GNU Autoconf 2.72a.18-fbdf. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ '$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Report bugs to the package provider." _ACEOF ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ octave sparsersb package config.status 1.0.9 configured by $0, generated by GNU Autoconf 2.72a.18-fbdf, with options \\"\$ac_cs_config\\" Copyright (C) 2021 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) printf "%s\n" "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) printf "%s\n" "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: '$1' Try '$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX printf "%s\n" "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "Makeconf") CONFIG_FILES="$CONFIG_FILES Makeconf" ;; *) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to '$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with './config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" eval set X " :F $CONFIG_FILES " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag '$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain ':'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: '$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is 'configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 printf "%s\n" "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`printf "%s\n" "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when '$srcdir' = '.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable 'datarootdir' which seems to be undefined. Please make sure it is defined" >&5 printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable 'datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $PACKAGE_NAME is configured with: SPARSERSB_LDFLAGS: $SPARSERSB_LDFLAGS SPARSERSB_CXXFLAGS: $SPARSERSB_CXXFLAGS SPARSERSB_CXX11: $SPARSERSB_CXX11 OCTAVE: $OCTAVE MKOCTFILE: $MKOCTFILE You can build it with 'make' and after on, test with 'make tests'. " >&5 printf "%s\n" "$as_me: $PACKAGE_NAME is configured with: SPARSERSB_LDFLAGS: $SPARSERSB_LDFLAGS SPARSERSB_CXXFLAGS: $SPARSERSB_CXXFLAGS SPARSERSB_CXX11: $SPARSERSB_CXX11 OCTAVE: $OCTAVE MKOCTFILE: $MKOCTFILE You can build it with 'make' and after on, test with 'make tests'. " >&6;}