CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-pycuda

Python wrapper for Nvidia CUDA parallel computation API with object cleanup, automatic error checking, and convenient abstractions.

62%

Overall

Evaluation62%

0.94x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-10/

Vector Field Calculator

Implement a GPU-accelerated calculator for computing properties of 2D vector fields. The calculator should perform element-wise arithmetic operations on vector components stored as GPU arrays.

Capabilities

Vector magnitude calculation

Compute the magnitude of 2D vectors using the formula: magnitude = sqrt(x^2 + y^2).

  • Given x-components [3.0, 4.0, 0.0] and y-components [4.0, 3.0, 5.0], returns magnitudes [5.0, 5.0, 5.0] @test
  • Given x-components [1.0, 0.0] and y-components [0.0, 1.0], returns magnitudes [1.0, 1.0] @test

Vector field addition

Add two vector fields component-wise.

  • Adding fields with x=[1.0, 2.0], y=[3.0, 4.0] and x=[5.0, 6.0], y=[7.0, 8.0] returns x=[6.0, 8.0], y=[10.0, 12.0] @test

Vector field scaling

Scale a vector field by a constant factor.

  • Scaling field x=[2.0, 4.0], y=[6.0, 8.0] by factor 0.5 returns x=[1.0, 2.0], y=[3.0, 4.0] @test
  • Scaling field x=[1.0, -1.0], y=[2.0, -2.0] by factor -2.0 returns x=[-2.0, 2.0], y=[-4.0, 4.0] @test

Vector field normalization

Normalize vectors in the field to unit length (magnitude = 1.0) by dividing each component by its magnitude. Handle zero-magnitude vectors by leaving them unchanged.

  • Given x=[3.0, 0.0], y=[4.0, 0.0], normalizes to x=[0.6, 0.0], y=[0.8, 0.0] @test
  • Given x=[5.0, 0.0], y=[0.0, 0.0], normalizes to x=[1.0, 0.0], y=[0.0, 0.0] @test

Implementation

@generates

API

import numpy as np
from typing import Tuple

def calculate_magnitude(x_components: np.ndarray, y_components: np.ndarray) -> np.ndarray:
    """
    Calculate the magnitude of 2D vectors using GPU acceleration.

    Args:
        x_components: Array of x-components
        y_components: Array of y-components

    Returns:
        Array of vector magnitudes
    """
    pass

def add_vector_fields(
    x1: np.ndarray, y1: np.ndarray,
    x2: np.ndarray, y2: np.ndarray
) -> Tuple[np.ndarray, np.ndarray]:
    """
    Add two vector fields component-wise using GPU acceleration.

    Args:
        x1, y1: First vector field components
        x2, y2: Second vector field components

    Returns:
        Tuple of (x_result, y_result) arrays
    """
    pass

def scale_vector_field(
    x: np.ndarray, y: np.ndarray, scale: float
) -> Tuple[np.ndarray, np.ndarray]:
    """
    Scale a vector field by a constant factor using GPU acceleration.

    Args:
        x, y: Vector field components
        scale: Scaling factor

    Returns:
        Tuple of (x_scaled, y_scaled) arrays
    """
    pass

def normalize_vector_field(
    x: np.ndarray, y: np.ndarray
) -> Tuple[np.ndarray, np.ndarray]:
    """
    Normalize vectors in the field to unit length using GPU acceleration.
    Zero-magnitude vectors remain unchanged.

    Args:
        x, y: Vector field components

    Returns:
        Tuple of (x_normalized, y_normalized) arrays
    """
    pass

Dependencies { .dependencies }

pycuda { .dependency }

Provides GPU-accelerated array operations for computing vector field properties.

@satisfied-by

tessl i tessl/pypi-pycuda@2025.1.0

tile.json