Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C# implemenation for 1D Convolutions #846

Conversation

stormofice
Copy link
Contributor

Requires .NET 5.0 [SDK Install instructions]

If you want to test this implementation on your machine, create a file in the code/csharp directory called code.csproj and paste the following into it:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net5.0</TargetFramework>
    </PropertyGroup>

</Project>

Now you can execute dotnet run to run the implementation.

@ntindle
Copy link
Member

ntindle commented Aug 28, 2021

[lang: c#]

@github-actions github-actions bot added the lang: c# C# programming language label Aug 28, 2021
@Amaras Amaras added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Aug 31, 2021
@Trashtalk217
Copy link
Contributor

I've attempted to check your code, but I haven't been able to run it yet. C# environments are a whole thing.

I've been able to check the website build, and there's still quite a lot to do there:
image
This is showing up in the Julia implementation and I have no clue why it is there.

If you need help with setting up honkit, please let me know.

@Trashtalk217 Trashtalk217 self-assigned this Sep 1, 2021
@Trashtalk217
Copy link
Contributor

I'll do a code review later, since I don't have much time:

The line numbers in the .md file are off for the Julia imports, make sure that looks good.
You've got an off by one error in your .dat files:

image

Here are the files generated by the Julia implementation for reference:
cyclic.txt
full_linear.txt
simple_linear.txt

Don't forget that Julia starts indexing at 1 for arrays and not 0.

@stormofice
Copy link
Contributor Author

stormofice commented Sep 3, 2021

Thanks for the review, I fixed the errors you described above and it now produces the following output [which seems to be correct]:
cyclic.txt

@Trashtalk217
Copy link
Contributor

The off-by-one error I noted for the cyclic convolution also exists in the other two convolutions.
Also, for the full-linear implementation, Julia generates an output file of 399 lines and you generate 400 lines. I'm guessing that that's a bug in the Julia implementation, however.

@stormofice
Copy link
Contributor Author

Thanks for the review, I forgot about the linear convolutions.

The errors should be fixed now; the full linear output includes a 0.0 at the end which the julia implementation does not, however if you print out the value at full_linear_output[output_size] (so the last value in the array) in the julia implementation, it also shows 0.0 and it just does not get written to file (that's my assumption at least).

The following outputs get produced:
full_linear.txt
simple_linear.txt

@jiegillet
Copy link
Member

jiegillet commented Sep 6, 2021

The line missing is probably because we did a ninja edit on the Julia code here: #854. Before that, there was a 0.0 at the end.
The right number of lines is definitely 399.

@stormofice
Copy link
Contributor Author

Oh it's the same PR that caused the problem with the Julia line numbers, I'll copy those changes then into the C# implementation.

@stormofice
Copy link
Contributor Author

@Trashtalk217 I think that all the aforementioned problems should be fixed now, if you want to take another look at this.

Copy link
Contributor

@Trashtalk217 Trashtalk217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of all things that don't matter, this review matters very little. I checked the build - looks good, and the output - also looks good. There's some minor picking at the comments but it looks great otherwise.

(I also used suggestions so you don't have to go into your editor again, I don't want to waste your time by havng you place periods.)

contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
contents/convolutions/code/csharp/1DConvolution.cs Outdated Show resolved Hide resolved
stormofice and others added 13 commits September 15, 2021 00:30
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
@stormofice
Copy link
Contributor Author

Should all be fixed now, thanks for the review.

@Trashtalk217 Trashtalk217 merged commit b86d137 into algorithm-archivists:master Sep 14, 2021
leios added a commit that referenced this pull request Oct 25, 2021
* pep8ify python

* rename Tree_example.py

* standardize python output

* standardize c output

* standardize c++ output

* standardize rust output

* standardize javascript output

* standardize julia output

* Standardized Coconut output

* fix coconut

* standardize go output

* standardize common lisp output

* Verlet Integration: Output standardization (#855)

* Standardize julia output

* Standardize kotlin output

This also fixes a previous bug, which caused the time and velocity
values to not get printed correctly.

* Standardized c output

* Standardized cpp output

* Standardized lisp output

* Standardized fortran output

I was not able to prevent the preceding whitespaces, but they can
just be trimmed.

* Standardized go output

* Standardized java output

* Standardize javascript output

* Standardize nim output

* Standardize python output

* Standardize ruby output

As the original implementation only returned the time and not
the velocity, the code needed to be adjusted a bit. Now it returns
the two values as an array which gets deconstructed and printed.

* Standardize rust output

* Standardize swift output

* Standardized haskell output

* Standardized haskell output (no quote marks)

* attempt at fix for asm

Co-authored-by: Jérémie Gillet <jie.gillet@gmail.com>
Co-authored-by: James Schloss <jrs.schloss@gmail.com>

* standardize php output

* standardize swift output

* removed outdated comments in Coconut implementation

* standardize haskell output

* Fix asm exit codes (#858)

* standardize crystal output

* Flood fill in Coconut (#836)

* Added Barnsley fern in Coconut (+ .editorconfig for Coconut) (#814)

* Added the Jarvis march in Coconut (#734)

* Fix minor typo

* Change folder structure of convolutions (#861)

This puts every chapters' code into its own directory, which is
useful for automatic validation.

* standardize csharp output

* standardize java output

* fix php line numbers and python filename

* fix coconut and python line numbers

* fix minor bug in C

* fix labels and minor bug in go

* minor label fix in python

* Huffman encoding in Coconut (#732)

* Update README.md

Changing readme link to reflect change in twitch url

* Add C# implemenation for 1D Convolutions (#846)

* Add C# implemenation for 1D Convolutions

* Fix off by one error and julia line numbers

* Fix off by one error for linear convolutions

* Fix trailing zero

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Update contents/convolutions/code/csharp/1DConvolution.cs

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* Add trailing new line

Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>

* IFS Common Lisp implementation (#722)

* first working version

* cleaned up the chaos-game function and added some helpfull comments

* changed the .md file and upped iterations

* Skeleton of the final solution

* Update contents/IFS/IFS.md

Co-authored-by: Eric Berquist <eric.berquist@gmail.com>

Co-authored-by: James Schloss <jrs.schloss@gmail.com>
Co-authored-by: Eric Berquist <eric.berquist@gmail.com>

* added MonteCarlo in PowerShell (#760)

* Add Rust implementation for The Barnsley Fern (#818)

* Add Rust implementation for The Barnsley Fern

* Change operators constants and add Cargo.toml

* Fix bug in matrix multiplication

Co-authored-by: James Schloss <jrs.schloss@gmail.com>

* changing barnsley.md to read the correct coconut file (#867)

* added approximate counting implementation in python (#866)

* added approximate counting implementation in python

* Update approximate_counting.py

* updating approximate_counting.py

* removed redundancies

* fixing linking issues in convolution chapter (#868)

* Add initial devcontainer (#862)

* small changes to convolutional theorem chapter and code to make things more reproduceable (#872)

* added convolutional theorem implementation in python (#869)

* added convolutional theorem implementation in python

* fixed chapter linking

* added comments to the code

* changed random distribution to sawtooth

* corrected previous commit

* fixed comments

Co-authored-by: James Schloss <jrs.schloss@gmail.com>

* Use `[#]\n` instead of `[#]` for human readable output (#873)

* Add approximate counting algorithm in C (#844)

* Add approximate counting algorithm in C

* Fix typo

Co-authored-by: stormofice <58337328+stormofice@users.noreply.github.com>

Co-authored-by: stormofice <58337328+stormofice@users.noreply.github.com>
Co-authored-by: James Schloss <jrs.schloss@gmail.com>

* added 1d convolution implementation in python (#874)

* added 1d convolution implementation in python

* fixed some mistakes in the code so it outputs correct results

* making the code look better

* spacing code properly for readability

* fixing 1d convolution markdown file (#879)

* Add racket setup to devcontainer (#875)

* Normalize inputs for scheme euclid algorithm (#878)

Change inputs to make it consistent with other examples.

* Add initial setup for Swift in devcontainer (#880)

* Add scheme setup to devcontainer (#876)

* Clean up Monte Carlo integration in Racket (#781)

* Clean up Monte Carlo integration in Racket

* Add blank lines in Monte Carlo integration in Clojure

* Change Racket lang include from lisp to racket

* Add C++ code for Flood Fill algorithm (#860)

* fixing chapter to use split-op code (#888)

* use [#]\n for readability

* Implemented stacks and queues in Java (#897)

* Java tree traversal: updated dfsRecursiveInOrderBinary (#899)

* Tree traversal in smalltalk (#453)

* fixed print statements (#901)

* Fixes in PATH that make dlang, emojicode and factor usable (#890)

* fixing huffman encoding for Julia and adding Test (#828)

* JavaScript tree traversal: updated dfsInorder (#902)

* julia: change printf to print

* pep8ify python

* rename Tree_example.py

* standardize python output

* standardize c output

* standardize c++ output

* standardize rust output

* standardize javascript output

Resolved conflict with master (by Amaras)

* standardize julia output

Resolved conflict with master (by Amaras)

* Standardized Coconut output

* fix coconut

* standardize go output

* standardize common lisp output

* standardize php output

* standardize swift output

* removed outdated comments in Coconut implementation

* standardize haskell output

* standardize crystal output

* standardize csharp output

* standardize java output

Resolved the conflict with fixing dfs

* fix php line numbers and python filename

* fix coconut and python line numbers

* fix minor bug in C

* fix labels and minor bug in go

* minor label fix in python

* use [#]\n for readability

* julia: change printf to print

* update Tree.java. remove MainClass.java

Co-authored-by: Sammy Plat <amaras@vivaldi.net>
Co-authored-by: stormofice <58337328+stormofice@users.noreply.github.com>
Co-authored-by: Jérémie Gillet <jie.gillet@gmail.com>
Co-authored-by: James Schloss <jrs.schloss@gmail.com>
Co-authored-by: Eric Berquist <eric.berquist@gmail.com>
Co-authored-by: Trashtalk217 <trashtalk217@gmail.com>
Co-authored-by: PaddyKe <34421580+PaddyKe@users.noreply.github.com>
Co-authored-by: Dimitri Belopopsky <ShadowMitia@users.noreply.github.com>
Co-authored-by: Ayman Lafaz <ayman.lafaz@um5r.ac.ma>
Co-authored-by: Nicholas Tindle <nicktindle@outlook.com>
Co-authored-by: Mahdi <24981501+mahdisarikhani@users.noreply.github.com>
Co-authored-by: Henrik Christensen <sensen1695@hotmail.com>
Co-authored-by: Neverik <neverliberty@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) lang: c# C# programming language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants