<commit_before>/***************************************************************************************************
 *  acos.swift
 *
 *  This file provides inverse cosine functionality.
 *
 *  Author: <NAME>
 *  Creation Date: 1 May 2016
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the 
 *  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
 *  express or implied. See the License for the specific language governing permissions and 
 *  limitations under the License.
 *
 *  Copyright 2016 <NAME>
 **************************************************************************************************/

/// Compute the arc cosine of x—that is, the value whose cosine is x. The value 
/// is in units of radians. Mathematically, there are infinitely many such 
/// values; the one actually returned is the one between 0 and pi (inclusive).
/// 
/// The arc cosine function is defined mathematically only over the domain -1 
/// to 1. If x is outside the domain, acos signals a domain error.

#if os(Linux)
@_exported import func Glibc.acos
#else
@_exported import func Darwin.acos
#endif

public func acos(_ v: Vector<Double>) -> Vector<Double>
{
    let newData = v.data.map({acos($0)})

    return Vector(newData, name: v.name, showName: v.showName)
}

public func acos(_ m: Matrix<Double>) -> Matrix<Double>
{
    let newData = m.data.map({acos($0)})

    return Matrix(m.size, newData, name: m.name, showName: m.showName)
}

public func acos(_ t: Tensor<Double>) -> Tensor<Double>
{
    let newData = t.data.map({acos($0)})

    return Tensor(t.size, newData, name: t.name, showName: t.showName)
}<commit_msg>Add comments (#41)<commit_after>/***************************************************************************************************
 *  acos.swift
 *
 *  This file provides inverse cosine functionality.
 *
 *  Author: <NAME>
 *  Creation Date: 1 May 2016
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the 
 *  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
 *  express or implied. See the License for the specific language governing permissions and 
 *  limitations under the License.
 *
 *  Copyright 2016 <NAME>
 **************************************************************************************************/

/// Compute the arc cosine of x—that is, the value whose cosine is x. The value 
/// is in units of radians. Mathematically, there are infinitely many such 
/// values; the one actually returned is the one between 0 and pi (inclusive).
/// 
/// The arc cosine function is defined mathematically only over the domain -1 
/// to 1. If x is outside the domain, acos signals a domain error.

#if os(Linux)
@_exported import func Glibc.acos
#else
@_exported import func Darwin.acos
#endif

/// Returns the inverse cosine (cos⁻¹) in radians for each element in a vector data structure.
///
/// - Parameter v: A vector data structure with elements to convert.
/// - Returns: A vector data structure with inverse cosine values.
///
/// - Warning: A domain error occurs for arguments not in the range [-1, +1].
public func acos(_ v: Vector<Double>) -> Vector<Double>
{
    let newData = v.data.map({acos($0)})

    return Vector(newData, name: v.name, showName: v.showName)
}

/// Returns the inverse cosine (cos⁻¹) in radians for each element in a matrix data structure.
///
/// - Parameter m: A matrix data structure with elements to convert.
/// - Returns: A matrix data structure with inverse cosine values.
///
/// - Warning: A domain error occurs for arguments not in the range [-1, +1].
public func acos(_ m: Matrix<Double>) -> Matrix<Double>
{
    let newData = m.data.map({acos($0)})

    return Matrix(m.size, newData, name: m.name, showName: m.showName)
}

/// Returns the inverse cosine (cos⁻¹) in radians for each element in a tensor data structure.
///
/// - Parameter t: A tensor data structure with elements to convert.
/// - Returns: A tensor data structure with inverse cosine values.
///
/// - Warning: A domain error occurs for arguments not in the range [-1, +1].
public func acos(_ t: Tensor<Double>) -> Tensor<Double>
{
    let newData = t.data.map({acos($0)})

    return Tensor(t.size, newData, name: t.name, showName: t.showName)
}
{'fraction_non_alphanumeric': 0.1812732534105002, 'fraction_numerical': 0.009508061182306739, 'mean_word_length': 3.7209756097560978, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5786825', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1306, 'n_words': 581}