Skip to main content

A package containing utility functions for matrix operations including transpose, 1D windowing, and 2D convolution.

Project description

martstelm_DE2v2.1.5

A package containing utility functions for matrix operations including transpose, 1D windowing, and 2D convolution.

Installation

You can install the package using pip:

pip install martstelm_DE2v2.1.5

Usage

Importing the Functions

from package.module import transpose2d, window1d, convolution2d

Functions

1. transpose2d

Transpose a 2D matrix.

Arguments:

  • input_matrix (List[List[float]]): A 2D list representing the matrix to be transposed.

Returns:

  • List[List[float]]: The transposed 2D list.

Example:

matrix = [
    [1, 2, 3],
    [4, 5, 6]
]

transposed_matrix = transpose2d(matrix)
print(transposed_matrix)
# Output: [[1, 4], [2, 5], [3, 6]]

2. window1d

Generate a 1D sliding window view of the input array.

Arguments:

  • input_array (Union[List, np.ndarray]): The input array.
  • size (int): The size of each window.
  • shift (int, optional): The shift between consecutive windows. Defaults to 1.
  • stride (int, optional): The stride within each window. Defaults to 1.

Returns:

  • List[Union[List, np.ndarray]]: A list of windows.

Example:

array = [1, 2, 3, 4, 5]
windows = window1d(array, size=3, shift=1)
print(windows)
# Output: [[1, 2, 3], [2, 3, 4], [3, 4, 5]]

3. convolution2d

Perform a 2D convolution on the input matrix using the given kernel.

Arguments:

  • input_matrix (np.ndarray): The input matrix.
  • kernel (np.ndarray): The convolution kernel.
  • stride (int, optional): The stride of the convolution. Defaults to 1.

Returns:

  • np.ndarray: The result of the convolution.

Example:

import numpy as np

input_matrix = np.array([
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
])

kernel = np.array([
    [1, 0],
    [0, -1]
])

convolution_result = convolution2d(input_matrix, kernel)
print(convolution_result)
# Output: [[ -4.  -4.]
#          [-4. -4.]]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mstturing-1.2.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mstturing-1.2.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file mstturing-1.2.0.tar.gz.

File metadata

  • Download URL: mstturing-1.2.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for mstturing-1.2.0.tar.gz
Algorithm Hash digest
SHA256 5f4852a2bed128242abc607ae3777a8cf4a740f9613716afd126f23c8b5102e4
MD5 4747d4c24af6d304f7e5b30aae5aff77
BLAKE2b-256 ff1c9ef605694d97197ffe5f03c3103958f7b94aa5088206923d0edb34a8f092

See more details on using hashes here.

File details

Details for the file mstturing-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: mstturing-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for mstturing-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4136bf6c006554f420f20b7cbb9c368ffc7962e12b9ff853aa8ddf163242b1c7
MD5 a499bf465acd10c7e934116bc4e40fd2
BLAKE2b-256 47042e73aad0879b9dcf95f10c5ea0025d2bb74fe9862a7b76270904b29e4451

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page