-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tbhaxor/v2
Implement more features and with operator overloading
- Loading branch information
Showing
530 changed files
with
25,486 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
{ | ||
"cmake.configureOnOpen": false | ||
"cmake.configureOnOpen": false, | ||
"[cmake]": { | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "twxs.cmake" | ||
}, | ||
"[cpp]": { | ||
"editor.formatOnSave": true, | ||
"editor.insertSpaces": false, | ||
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd", | ||
"editor.tabSize": 2 | ||
}, | ||
"files.associations": { | ||
"/Doxfile": "doxygen" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,34 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
project(firefly) | ||
project(firefly LANGUAGES CXX VERSION 2.0.0) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
add_compile_options(-std=c++17) | ||
|
||
set (CMAKE_CXX_STANDARD 17) | ||
set(${PROJECT_NAME}_VERSION_MAJOR 2) | ||
set(${PROJECT_NAME}_VERSION_MINOR 0) | ||
set(${PROJECT_NAME}_VERSION_PATCH 0) | ||
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}) | ||
option(Firefly_ENABLE_DOUBLE_PRECISION "Whether or not to enable double precision. If this is false, float will be used." OFF) | ||
option(Firefly_ENABLE_EXAMPLES "Whether or not to enable examples" OFF) | ||
|
||
if (${Firefly_ENABLE_DOUBLE_PRECISION}) | ||
add_definitions(-DDOUBLE_PRECISION=1) | ||
endif() | ||
|
||
include_directories(headers) | ||
|
||
add_library(${PROJECT_NAME}_static STATIC) | ||
add_library(${PROJECT_NAME}_shared SHARED) | ||
|
||
set_target_properties(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) | ||
set_target_properties(${PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) | ||
|
||
add_library(Firefly::Shared ALIAS ${PROJECT_NAME}_shared) | ||
add_library(Firefly::Static ALIAS ${PROJECT_NAME}_static) | ||
|
||
include_directories(INCLUDES) | ||
add_subdirectory(src) | ||
add_subdirectory(tests) | ||
|
||
if (${Firefly_ENABLE_EXAMPLES}) | ||
message(STATUS "Enabling examples build") | ||
add_subdirectory(examples) | ||
endif() | ||
|
||
install(TARGETS ${PROJECT_NAME}_static ${PROJECT_NAME}_shared) | ||
install(DIRECTORY headers/ DESTINATION includes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#--------------------------------------------------------------------------- | ||
# Doxyfile for C++ documentation | ||
#--------------------------------------------------------------------------- | ||
|
||
PROJECT_NAME = "Firefly" | ||
PROJECT_BRIEF = "Standalone library for vector and matrix calculations" | ||
PROJECT_NUMBER = "2.0" | ||
|
||
|
||
FILE_PATTERNS = *.cpp *.hpp | ||
INPUT = ./headers ./src | ||
RECURSIVE = YES | ||
EXAMPLE_PATH = ./examples | ||
OUTPUT_DIRECTORY = ./docs | ||
|
||
SHOW_FILES = YES | ||
|
||
ENABLED_SECTIONS = mainpage | ||
|
||
EXTRACT_ALL = YES | ||
|
||
HAVE_DOT = NO | ||
|
||
UML_LOOK = YES | ||
|
||
GENERATE_HTML = YES | ||
|
||
HTML_OUTPUT = ./ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,53 @@ | ||
<br> | ||
# Firefly | ||
|
||
# Firefly [![Build Status](https://travis-ci.org/tbhaxor/firefly.svg?branch=master)](https://travis-ci.org/tbhaxor/firefly) | ||
This is a standalone C++ vector calculation library. It performs addition, subtraction, scalar multiplication, magnitude, normalisation, dot product, cross product, area of parallelogram, area of triangle, and angle between two vectors. The library supports both float and double precision and cuurrently it is only available on the CPU systems. | ||
|
||
> A standalone C++ Library for vectors calculations | ||
The library was designed to help people learn C++ and its concepts. It's a simple implementation, but it's a good place to start if you want to learn more about linear algebra and C++. | ||
|
||
# Installation | ||
## Example Usage | ||
|
||
1. Download the repository or clone | ||
```sh | ||
git clone https://github.com/tbhaxor/firefly.git | ||
``` | ||
2. Change the directory to firefly | ||
```sh | ||
cd firefly | ||
``` | ||
3. Make a build directory | ||
```sh | ||
mkdir build | ||
``` | ||
4. Configure the Project | ||
```sh | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr | ||
``` | ||
5. Make the package | ||
```sh | ||
make | ||
``` | ||
6. Install the package | ||
```sh | ||
sudo make install | ||
``` | ||
7. Copy the file(s) from `INCLUDES` directory to `/usr/include` | ||
```c++ | ||
#include <iostream> | ||
#include <vector> | ||
|
||
# Datatypes and classes | ||
|
||
1. vector of `float` type | ||
2. Vectors class of `firefly` | ||
|
||
# Features | ||
|
||
1. Addition of two vectors | ||
2. Subtraction of two vectors | ||
3. Scalor Multiplication of the floating number with Vector | ||
4. Find vector magnitude | ||
5. Find normalized form of the vector i.e unit vector | ||
6. Find dot product of two vectors | ||
7. Find cross product of two vectors | ||
8. Find area of parallelogram formed by two vectors | ||
9. Find area of triangle formed by two vectors | ||
10. Find angle between two vector in _degrees_ or _radians_ | ||
11. Check whether the two vectors are parallel to each other or not | ||
12. Check whether the two vectors are orthogonal to each other or not | ||
13. Find a component of vector parallel to base vector while vector projection | ||
14. Find a component of vector orthogonal to base vector while vector projection | ||
|
||
# Example | ||
|
||
Here I will demonstrate you a function to print vector components <br> | ||
**Note :** The following code will work if you have added both `firefly` and `firefly.hpp` to the **includes** directory of your compiler | ||
|
||
```cpp | ||
#include <firefly.hpp> | ||
#include <iostream> // for io operations | ||
#include <vector> // for dynamic arrays :P | ||
using namespace std; | ||
#include <firefly/vector.hpp> | ||
|
||
int main() { | ||
vector<float> array = {1, 2, 3}; | ||
Vectors vec1(array); // Vectors is the class in firefly | ||
vec1.print(); // print is the method of class | ||
return 0; | ||
// define two vectors | ||
std::vector<Real> vec1{1, 2, 3, 4}; | ||
std::vector<Real> vec2{2, 3, 4, 1}; | ||
|
||
// define firefly vectors from std::vector | ||
Firefly::Vector v1(vec1); | ||
Firefly::Vector v2(vec2); | ||
|
||
// add two firefly vectors and | ||
// returns unique_ptr of Firefly::Vector type | ||
std::unique_ptr<Firefly::Vector> vec_addition = v1 + v2; | ||
|
||
// print out v1 on | ||
std::cout << v1 << std::endl; // [1, 2, 3, 4] | ||
std::cout << v2 << std::endl; // [2, 3, 4, 1] | ||
std::cout << *vec_addition << std::endl; // [3, 5, 7, 5] | ||
} | ||
``` | ||
|
||
**OUTPUT** | ||
### Using `CMake` | ||
|
||
```cmake | ||
# for shared linking | ||
target_link_libraries(${PROJECT_NAME} PUBLIC Firefly::Shared) | ||
# for static linking | ||
target_link_libraries(${PROJECT_NAME} PUBLIC Firefly::Static) | ||
``` | ||
[1, 2, 3, ] | ||
``` | ||
|
||
**Note:** Learn how to integrate firefly with cmake from [this](https://github.com/tbhaxor/firefly/tree/master/examples) example | ||
## Future Plans | ||
|
||
- Implement Kokkos for HPC platforms | ||
|
||
# CONTRIBUTION | ||
## Contact | ||
|
||
To contribute open a Pull Request from new branch | ||
Email: tbhaxor@proton.me <br /> | ||
Twitter: @tbhaxor <br /> | ||
LinkedIn: @tbhaxor |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> | ||
<meta http-equiv="X-UA-Compatible" content="IE=11"/> | ||
<meta name="generator" content="Doxygen 1.9.7"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"/> | ||
<title>Firefly: src/vector/add.cpp File Reference</title> | ||
<link href="tabs.css" rel="stylesheet" type="text/css"/> | ||
<script type="text/javascript" src="jquery.js"></script> | ||
<script type="text/javascript" src="dynsections.js"></script> | ||
<link href="search/search.css" rel="stylesheet" type="text/css"/> | ||
<script type="text/javascript" src="search/searchdata.js"></script> | ||
<script type="text/javascript" src="search/search.js"></script> | ||
<link href="doxygen.css" rel="stylesheet" type="text/css" /> | ||
</head> | ||
<body> | ||
<div id="top"><!-- do not remove this div, it is closed by doxygen! --> | ||
<div id="titlearea"> | ||
<table cellspacing="0" cellpadding="0"> | ||
<tbody> | ||
<tr id="projectrow"> | ||
<td id="projectalign"> | ||
<div id="projectname">Firefly<span id="projectnumber"> 2.0</span> | ||
</div> | ||
<div id="projectbrief">Standalone library for vector and matrix calculations</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<!-- end header part --> | ||
<!-- Generated by Doxygen 1.9.7 --> | ||
<script type="text/javascript"> | ||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ | ||
var searchBox = new SearchBox("searchBox", "search/",'.html'); | ||
/* @license-end */ | ||
</script> | ||
<script type="text/javascript" src="menudata.js"></script> | ||
<script type="text/javascript" src="menu.js"></script> | ||
<script type="text/javascript"> | ||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ | ||
$(function() { | ||
initMenu('',true,false,'search.php','Search'); | ||
$(document).ready(function() { init_search(); }); | ||
}); | ||
/* @license-end */ | ||
</script> | ||
<div id="main-nav"></div> | ||
<!-- window showing the filter options --> | ||
<div id="MSearchSelectWindow" | ||
onmouseover="return searchBox.OnSearchSelectShow()" | ||
onmouseout="return searchBox.OnSearchSelectHide()" | ||
onkeydown="return searchBox.OnSearchSelectKey(event)"> | ||
</div> | ||
|
||
<!-- iframe showing the search results (closed by default) --> | ||
<div id="MSearchResultsWindow"> | ||
<div id="MSearchResults"> | ||
<div class="SRPage"> | ||
<div id="SRIndex"> | ||
<div id="SRResults"></div> | ||
<div class="SRStatus" id="Loading">Loading...</div> | ||
<div class="SRStatus" id="Searching">Searching...</div> | ||
<div class="SRStatus" id="NoMatches">No Matches</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div id="nav-path" class="navpath"> | ||
<ul> | ||
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_0baa9f3d984dd29d1429171590d769d6.html">vector</a></li> </ul> | ||
</div> | ||
</div><!-- top --> | ||
<div class="header"> | ||
<div class="summary"> | ||
<a href="#namespaces">Namespaces</a> </div> | ||
<div class="headertitle"><div class="title">add.cpp File Reference</div></div> | ||
</div><!--header--> | ||
<div class="contents"> | ||
<div class="textblock"><code>#include <algorithm></code><br /> | ||
<code>#include <cmath></code><br /> | ||
<code>#include <stdexcept></code><br /> | ||
<code>#include "<a class="el" href="vector_8hpp_source.html">firefly/vector.hpp</a>"</code><br /> | ||
</div><table class="memberdecls"> | ||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a> | ||
Namespaces</h2></td></tr> | ||
<tr class="memitem:namespaceFirefly"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceFirefly.html">Firefly</a></td></tr> | ||
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> | ||
</table> | ||
</div><!-- contents --> | ||
<!-- start footer part --> | ||
<hr class="footer"/><address class="footer"><small> | ||
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7 | ||
</small></address> | ||
</body> | ||
</html> |
Oops, something went wrong.