matrix-operations

module
v0.0.0-...-1d7e4ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2021 License: MIT

README

Matrix Handling Web Server

Program to handle a matrix from a CSV file and perform a few operations on it.


Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Future improvements
  5. Contributing
  6. License
  7. Contact

About The Project

This is a simple project to handle a matrix from a CSV file and perform a few operations on it.

Given an uploaded csv file

1,2,3
4,5,6
7,8,9

The following operations should be available:

  1. Echo
    • Return the matrix as a string in matrix format.
    // Expected output
    1,2,3
    4,5,6
    7,8,9
    
  2. Invert
    • Return the matrix as a string in matrix format where the columns and rows are inverted
    // Expected output
    1,4,7
    2,5,8
    3,6,9
    
  3. Flatten
    • Return the matrix as a 1 line string, with values separated by commas.
    // Expected output
    1,2,3,4,5,6,7,8,9
    
  4. Sum
    • Return the sum of the integers in the matrix
    // Expected output
    45
    
  5. Multiply
    • Return the product of the integers in the matrix
    // Expected output
    362880
    

The input file to these functions is a matrix, of any dimension where the number of rows are equal to the number of columns (square). Each value is an integer, and there is no header row. resources/matrix.csv is an example of a valid input.

Built With

  • Go 1.14

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

Make sure Go is installed in your machine. Run the following command to confirm:

$ go version
go version go1.14 windows/amd64

Installation

  1. Clone the repo
$ git clone https://github.com/julioromanoreal/matrix-operations.git
  1. Start the application
$ go run cmd/matrix-operations/main.go

Usage

The following endpoints will be available:

  1. Echo: http://localhost:8080/echo:
curl -F 'file=@/path/matrix.csv' "localhost:8080/echo"
  1. Flatten: http://localhost:8080/flatten:
curl -F 'file=@/path/matrix.csv' "localhost:8080/flatten"
  1. Invert: http://localhost:8080/invert:
curl -F 'file=@/path/matrix.csv' "localhost:8080/invert"
  1. Sum: http://localhost:8080/sum:
curl -F 'file=@/path/matrix.csv' "localhost:8080/sum"
  1. Multiply: http://localhost:8080/multiply:
curl -F 'file=@/path/matrix.csv' "localhost:8080/multiply"

Future improvements

  • Consider protecting the URLs using JWT
  • Consider using gorilla/mux in the web server

Contributing

Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Julio Romano - @julioromano_ - julio.romano@gmail.com

Project Link: https://github.com/julioromanoreal/matrix-operations

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL