Skip to content

Commit

Permalink
Merge pull request #20 from HamletTanyavong/dev
Browse files Browse the repository at this point in the history
Add rank one and two tensors
  • Loading branch information
HamletTanyavong authored Oct 27, 2023
2 parents d237eb4 + 900f99d commit 07caa46
Show file tree
Hide file tree
Showing 39 changed files with 1,263 additions and 71 deletions.
3 changes: 3 additions & 0 deletions docs/articles/differential_geometry/tensors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Tensors

[work in progress]
2 changes: 1 addition & 1 deletion docs/articles/intro.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Mathematics.NET Articles

Welcome to Mathematics.NET.
This section is dedicated to highlighting areas of math covered in this library.
10 changes: 3 additions & 7 deletions docs/articles/toc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
- name: Introduction
href: intro.md
- name: Get Started
- name: Differential Geometry
items:
- name: Installation
href: get_started/installation.md
- name: Fundamentals
items:
- name: Numeric Types
href: fundamentals/numeric-types.md
- name: Tensors
href: differential_geometry/tensors.md
17 changes: 4 additions & 13 deletions docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,8 @@
"build": {
"content": [
{
"files": [
"api/**.yml",
"api/index.md"
]
},
{
"files": [
"articles/**.md",
"articles/**/toc.yml",
"toc.yml",
"*.md"
]
"files": [ "**/*.{md,yml}" ],
"exclude": [ "_site/**", "obj/**" ]
}
],
"resource": [
Expand All @@ -49,7 +39,8 @@
"fileMetadataFiles": [],
"template": [
"default",
"modern"
"modern",
"template"
],
"postProcessors": [ "ExtractSearchIndex" ],
"keepFileLink": false,
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions docs/guide/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Mathematics.NET Guide

Welcome to Mathematics.NET.
10 changes: 10 additions & 0 deletions docs/guide/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: Introduction
href: intro.md
- name: Get Started
items:
- name: Installation
href: get_started/installation.md
- name: Fundamentals
items:
- name: Numeric Types
href: fundamentals/numeric-types.md
58 changes: 58 additions & 0 deletions docs/template/public/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
:root, [data-bs-theme="dark"] {
--bg-color-primary: #161616;
--bg-color-secondary: #082424;
}

[data-bs-theme="light"] {
--bg-color-primary: #e4e4e4;
--bg-color-secondary: #b4f8f8;
}

header {
--bs-border-width: 0px;
}

body {
background-color: var(--bg-color-primary);
}

body > footer {
display: flex;
align-items: center;
padding: 0rem;
height: 3rem;
}

footer {
background-color: var(--bg-color-secondary);
font-size: 0.75rem;
}

footer.border-top{
border-top: 0px;
}

a {
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

.bg-body {
background-color: var(--bg-color-secondary);
}

.dropdown a:hover {
text-decoration: none;
}

.dropdown-menu[data-bs-popper] {
background-color: var(--bg-color-secondary);
margin-top: 1.125rem;
}

.dropdown-menu a:hover {
text-decoration: none;
}
15 changes: 15 additions & 0 deletions docs/template/public/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default {
defaultTheme: 'dark',
iconLinks: [
{
icon: 'github',
href: 'https://github.com/HamletTanyavong/Mathematics.NET',
title: 'GitHub'
},
{
icon: 'heart',
href: 'https://github.com/sponsors/HamletTanyavong',
title: 'Sponsor'
}
]
}
7 changes: 4 additions & 3 deletions docs/toc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- name: Guide
href: guide/
- name: API
href: api/
- name: Articles
href: articles/
- name: Api Documentation
href: api/
homepage: api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public sealed class DerivativesBuilder
private readonly string _assemblyName;
private readonly ImmutableArray<MethodInformation> _methodInformation;

public DerivativesBuilder(Compilation compilationUnitSyntax, ImmutableArray<MethodInformation> methodInformation)
public DerivativesBuilder(Compilation compilation, ImmutableArray<MethodInformation> methodInformation)
{
_assemblyName = compilationUnitSyntax.AssemblyName!;
_assemblyName = compilation.AssemblyName!;
_methodInformation = methodInformation;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public MultiplyByScalarAction(T factor)
_factor = factor;
}

/// <summary>Executes the action on an item of type <typeparamref name="T"/></summary>
/// <param name="item">The item</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Invoke(ref T item) => item *= _factor;
}
35 changes: 35 additions & 0 deletions src/Mathematics.NET/DifferentialGeometry/Abstractions/IIndex.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// <copyright file="IIndex.cs" company="Mathematics.NET">
// Mathematics.NET
// https://github.com/HamletTanyavong/Mathematics.NET
//
// MIT License
//
// Copyright (c) 2023 Hamlet Tanyavong
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </copyright>

namespace Mathematics.NET.DifferentialGeometry.Abstractions;

/// <summary>Defines support for tensor indices</summary>
public interface IIndex : IFormattable
{
/// <summary>Gets an instance of this struct</summary>
static abstract IIndex Instance { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// <copyright file="IIndexPosition.cs" company="Mathematics.NET">
// Mathematics.NET
// https://github.com/HamletTanyavong/Mathematics.NET
//
// MIT License
//
// Copyright (c) 2023 Hamlet Tanyavong
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </copyright>

namespace Mathematics.NET.DifferentialGeometry.Abstractions;

/// <summary>Represents an index position</summary>
public interface IIndexPosition
{
/// <summary>Get a string representation of the index position</summary>
static abstract string DisplayString { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// <copyright file="IRankOneTensor.cs" company="Mathematics.NET">
// Mathematics.NET
// https://github.com/HamletTanyavong/Mathematics.NET
//
// MIT License
//
// Copyright (c) 2023 Hamlet Tanyavong
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </copyright>

using Mathematics.NET.LinearAlgebra.Abstractions;

namespace Mathematics.NET.DifferentialGeometry.Abstractions;

/// <summary>Defines support for rank-one tensors</summary>
/// <typeparam name="T">The type that implements the interface</typeparam>
/// <typeparam name="U">A backing type that implements <see cref="IVector{T, U}"/></typeparam>
/// <typeparam name="V">A type that implements <see cref="IComplex{T}"/></typeparam>
/// <typeparam name="W">An index</typeparam>
public interface IRankOneTensor<T, U, V, W> : IOneDimensionalArrayRepresentable<T, V>
where T : IRankOneTensor<T, U, V, W>
where U : IVector<U, V>
where V : IComplex<V>
where W : IIndex
{
/// <summary>Get the index associated with this rank one tensor</summary>
IIndex Index { get; }

/// <summary>Convert a value that implements <see cref="IVector{T, U}"/> to one of type <typeparamref name="T"/></summary>
/// <param name="input">The value to convert</param>
static abstract implicit operator T(U input);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// <copyright file="IRankTwoTensor.cs" company="Mathematics.NET">
// Mathematics.NET
// https://github.com/HamletTanyavong/Mathematics.NET
//
// MIT License
//
// Copyright (c) 2023 Hamlet Tanyavong
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </copyright>

using Mathematics.NET.LinearAlgebra.Abstractions;

namespace Mathematics.NET.DifferentialGeometry.Abstractions;

/// <summary>Defines support for rank-two tensors</summary>
/// <typeparam name="T">The type that implements the interface</typeparam>
/// <typeparam name="U">A backing type that implements <see cref="ISquareMatrix{T, U}"/></typeparam>
/// <typeparam name="V">A type that implements <see cref="IComplex{T}"/></typeparam>
/// <typeparam name="W">An index</typeparam>
/// <typeparam name="X">An index</typeparam>
public interface IRankTwoTensor<T, U, V, W, X> : ITwoDimensionalArrayRepresentable<T, V>
where T : IRankTwoTensor<T, U, V, W, X>
where U : ISquareMatrix<U, V>
where V : IComplex<V>
where W : IIndex
where X : IIndex
{
/// <summary>Get the indices associated with this rank two tensor</summary>
IIndex[] Indices { get; }

/// <summary>Convert a value that implements <see cref="IMatrix{T, U}"/> to one of type <typeparamref name="T"/></summary>
/// <param name="input">The value to convert</param>
static abstract implicit operator T(U input);
}
Loading

0 comments on commit 07caa46

Please sign in to comment.