<commit_before>;;   Copyright (c) <NAME>. All rights reserved.
;;   The use and distribution terms for this software are covered by the
;;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) or later
;;   which can be found in the file LICENSE at the root of this distribution.
;;   By using this software in any fashion, you are agreeing to be bound by
;;   the terms of this license.
;;   You must not remove this notice, or any other, from this software.

(ns uncomplicate.neanderthal.internal.host.buffer-block
  (:require [uncomplicate.commons.core
             :refer [Releaseable release let-release double-fn wrap-float wrap-double wrap-int wrap-long]]
            [uncomplicate.fluokitten.protocols
             :refer [PseudoFunctor Functor Foldable Magma Monoid Applicative fold]]
            [uncomplicate.neanderthal
             [core :refer [transfer! copy! subvector]]
             [real :refer [entry entry!]]
             [math :refer [ceil]]]
            [uncomplicate.neanderthal.internal
             [api :refer :all]
             [common :refer [dense-rows dense-cols dense-dias region-dias region-cols region-rows
                             lu-factorization pivotless-lu-factorization dual-lu-factorization
                             dragan-says-ex real-accessor require-trf]]
             [printing :refer [print-vector print-ge print-uplo print-banded print-diagonal]]
             [navigation :refer :all]]
            [uncomplicate.neanderthal.internal.host.fluokitten :refer :all])
  (:import [java.nio ByteBuffer DirectByteBuffer ByteOrder]
           [clojure.lang Seqable IFn IFn$DD IFn$DDD IFn$DDDD IFn$DDDDD IFn$LD IFn$LLD IFn$L IFn$LL
            IFn$LDD IFn$LLDD IFn$LLL]
           [uncomplicate.neanderthal.internal.api BufferAccessor RealBufferAccessor IntegerBufferAccessor
            VectorSpace Vector RealVector Matrix IntegerVector DataAccessor RealChangeable IntegerChangeable
            RealNativeMatrix RealNativeVector IntegerNativeVector DenseStorage FullStorage RealDefault
            LayoutNavigator RealLayoutNavigator Region MatrixImplementation GEMatrix UploMatrix
            BandedMatrix PackedMatrix DiagonalMatrix]
           uncomplicate.neanderthal.internal.navigation.BandStorage))

(defn ^:private hash* ^double [^double h ^double x]
  (double (clojure.lang.Util/hashCombine h (Double/hashCode x))))

(def ^:private f* (double-fn *))

(defn ^:private direct-buffer [^long size]
  (let [buff (ByteBuffer/allocateDirect size)]
    (.order ^ByteBuffer buff (ByteOrder/nativeOrder))
    buff))

(defn ^:private slice-buffer [^ByteBuffer buf ^long ofst ^long len]
  (when buf
    (let [ord (.order buf)
          res (.duplicate buf)]
      (.position res ofst)
      (.limit res (+ ofst len))
      (.slice res)
      (.order res)
      res)))

;; ================== Declarations ============================================

(declare integer-block-vector)
(declare real-block-vector)
(declare real-ge-matrix)
(declare real-uplo-matrix)
(declare real-banded-matrix)
(declare real-packed-matrix)
(declare real-diagonal-matrix)

;; ============ Real Buffer ====================================================

(deftype FloatBufferAccessor []
  DataAccessor
  (entryType [_]
    Float/TYPE)
  (entryWidth [_]<commit_msg>Use commons.utils/direct-buffer and slice-buffer.<commit_after>;;   Copyright (c) <NAME>. All rights reserved.
;;   The use and distribution terms for this software are covered by the
;;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) or later
;;   which can be found in the file LICENSE at the root of this distribution.
;;   By using this software in any fashion, you are agreeing to be bound by
;;   the terms of this license.
;;   You must not remove this notice, or any other, from this software.

(ns uncomplicate.neanderthal.internal.host.buffer-block
  (:require [uncomplicate.commons
             [core :refer [Releaseable release let-release double-fn wrap-float wrap-double wrap-int wrap-long]]
             [utils :refer [direct-buffer slice-buffer]]]
            [uncomplicate.fluokitten.protocols
             :refer [PseudoFunctor Functor Foldable Magma Monoid Applicative fold]]
            [uncomplicate.neanderthal
             [core :refer [transfer! copy! subvector]]
             [real :refer [entry entry!]]
             [math :refer [ceil]]]
            [uncomplicate.neanderthal.internal
             [api :refer :all]
             [common :refer [dense-rows dense-cols dense-dias region-dias region-cols region-rows
                             lu-factorization pivotless-lu-factorization dual-lu-factorization
                             dragan-says-ex real-accessor require-trf]]
             [printing :refer [print-vector print-ge print-uplo print-banded print-diagonal]]
             [navigation :refer :all]]
            [uncomplicate.neanderthal.internal.host.fluokitten :refer :all])
  (:import [java.nio ByteBuffer DirectByteBuffer]
           [clojure.lang Seqable IFn IFn$DD IFn$DDD IFn$DDDD IFn$DDDDD IFn$LD IFn$LLD IFn$L IFn$LL
            IFn$LDD IFn$LLDD IFn$LLL]
           [uncomplicate.neanderthal.internal.api BufferAccessor RealBufferAccessor IntegerBufferAccessor
            VectorSpace Vector RealVector Matrix IntegerVector DataAccessor RealChangeable IntegerChangeable
            RealNativeMatrix RealNativeVector IntegerNativeVector DenseStorage FullStorage RealDefault
            LayoutNavigator RealLayoutNavigator Region MatrixImplementation GEMatrix UploMatrix
            BandedMatrix PackedMatrix DiagonalMatrix]
           uncomplicate.neanderthal.internal.navigation.BandStorage))

(defn ^:private hash* ^double [^double h ^double x]
  (double (clojure.lang.Util/hashCombine h (Double/hashCode x))))

(def ^:private f* (double-fn *))

;; ================== Declarations ============================================

(declare integer-block-vector)
(declare real-block-vector)
(declare real-ge-matrix)
(declare real-uplo-matrix)
(declare real-banded-matrix)
(declare real-packed-matrix)
(declare real-diagonal-matrix)

;; ============ Real Buffer ====================================================

(deftype FloatBufferAccessor []
  DataAccessor
  (entryType [_]
    Float/TYPE)
  (entryWidth [_]
{'fraction_non_alphanumeric': 0.12863268222963317, 'fraction_numerical': 0.0012704462442432905, 'mean_word_length': 3.2127090301003345, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6615143', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1737, 'n_words': 499}