benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1ffabccb-fb16-5164-896c-a023a98060e3

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import numpy as np
from scipy.linalg import svd

def task_func(rows=3, columns=2, seed=0):
    """
    Generate a matrix of random values with specified dimensions and perform Singular Value Decomposition (SVD) on it.

    Requirements:
    - numpy
    - scipy.linalg.svd

    Parameters:
    - rows (int): Number of rows for the random matrix. Default is 3.
    - columns (int): Number of columns for the random matrix. Default is 2.
    - seed (int, optional): Seed for the random number generator to ensure reproducibility. Default is None.

    Returns:
    tuple: A tuple containing three elements:
        - U (ndarray): The unitary matrix U.
        - s (ndarray): The singular values, sorted in descending order.
        - Vh (ndarray): The conjugate transpose of the unitary matrix V.

    Example:
    >>> U, s, Vh = task_func(3, 2, seed=42)
    >>> print('U shape:', U.shape)
    U shape: (3, 3)
    >>> print('s shape:', s.shape)
    s shape: (2,)
    >>> print('Vh shape:', Vh.shape)
    Vh shape: (2, 2)
    """

instruct prompt

Generate a matrix of random values with specified dimensions and perform Singular Value Decomposition (SVD) on it.
The function should output with:
    tuple: A tuple containing three elements:
    U (ndarray): The unitary matrix U.
    s (ndarray): The singular values, sorted in descending order.
    Vh (ndarray): The conjugate transpose of the unitary matrix V.
You should write self-contained code starting with:

Code

import numpy as np
from scipy.linalg import svd
def task_func(rows=3, columns=2, seed=0):

code prompt

Code

import numpy as np
from scipy.linalg import svd
def task_func(rows=3, columns=2, seed=0):

entry point

task_func

libs

  • numpy
  • scipy

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import