Giter Club home page Giter Club logo

Comments (1)

fommil avatar fommil commented on June 30, 2024

btw, this is the sort of thing we should be doing

/*
  gcc -O3 mkl-bug.c common.c -o mkl-bug -I. -L. -lblas -lgfortran -lm

  Then choosing the backend is a runtime choice:

  LD_LIBRARY_PATH=. ./mkl-bug
  LD_LIBRARY_PATH=/usr/lib/atlas-base:. ./mkl-bug
  LD_LIBRARY_PATH=/usr/lib/openblas-base:. ./mkl-bug
  LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:. ./mkl-bug
*/

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cblas.h>
#include "common.h"

int main() {
    int m = 5;
    int n = 5;
    double a[25] = {
        1.0, 0.0, 0.0, 0.0, 0.0,
        0.0, 1.0, 0.0, 0.0, 0.0,
        0.0, 0.0, 1.0, 0.0, 0.0,
        0.0, 0.0, 0.0, 1.0, 0.0,
        0.0, 0.0, 0.0, 0.0, 1.0
    };
    int lda = 5;
    int jpvt[5] = { 0, 0, 0, 0, 0 };
    double tau[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
    double *work;
    int lwork = -1;
    int info = 0;
    double optimal = 0.0;
    int i, j;

    dgeqp3( &m, &n, a, &lda, jpvt, tau, &optimal, &lwork, &info );

    lwork = (int)optimal;
    printf("optimal = %i\n", lwork);

    work = malloc(lwork * sizeof(*work));

    dgeqp3( &m, &n, a, &lda, jpvt, tau, work, &lwork, &info );

    printf("result = %i\n", info);
    for(i = 0; i < 5; i++) {
        for(j = 0; j < 5; j++) {
            printf("%f ", a[j * 5 + i]);
        }
        printf("\n");
    }

    free(work);

    return(0);
}

from matrix-toolkits-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.