Skip to main content

openblas 0.1.0 copy "openblas: ^0.1.0" to clipboard
openblas: ^0.1.0 copied to clipboard

FFI bindings for OpenBLAS.

example/openblas_example.dart

// Copyright 2026 Google LLC
//
// 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.

import 'dart:ffi' as ffi;
import 'package:ffi/ffi.dart';
import 'package:openblas/openblas.dart';

void main() {
  final threads = openblas_get_num_threads();
  print('OpenBLAS threads: $threads');

  final configPtr = openblas_get_config();
  final configStr = configPtr.cast<Utf8>().toDartString();
  print('OpenBLAS Config: $configStr');

  // Simple calculation: Vector dot product (cblas_sdot)
  final n = 3;
  final x = calloc<ffi.Float>(n);
  final y = calloc<ffi.Float>(n);

  x[0] = 1.0;
  x[1] = 2.0;
  x[2] = 3.0;
  y[0] = 4.0;
  y[1] = 5.0;
  y[2] = 6.0;

  final result = cblas_sdot(n, x, 1, y, 1);
  print('sdot result: $result (Expected: 32.0)');

  calloc.free(x);
  calloc.free(y);
}
0
likes
130
points
188
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

FFI bindings for OpenBLAS.

Repository (GitHub)
View/report issues
Contributing

License

Apache-2.0 (license)

Dependencies

archive, code_assets, crypto, ffi, hooks

More

Packages that depend on openblas