Skip to content

Instantly share code, notes, and snippets.

View weslleyspereira's full-sized avatar

Weslley S. Pereira weslleyspereira

View GitHub Profile
@weslleyspereira
weslleyspereira / has_member.cpp
Created October 24, 2022 21:05
Check if a class has a specific attribute
/** Defines structures that check if opts_t has an attribute called member.
*
* has_member<opts_t> is a true type if the struct opts_t has an attribute called member.
* has_member_v<opts_t> is true if the struct opts_t has a member called member.
*
* @param member Attribute to be checked
*
* @see https://stackoverflow.com/questions/1005476/how-to-detect-whether-there-is-a-specific-member-variable-in-class
*/
#define MEMBER_CHECKER(member) \
@weslleyspereira
weslleyspereira / test_zcomplexabs.f
Last active September 1, 2021 19:23
Test double complex division in Fortran
*> \brief zabs tests the robustness and precision of the intrinsic ABS for double complex
*> \author Weslley S. Pereira, University of Colorado Denver, U.S.
*
*> \verbatim
*>
*> Real values for test:
*> (1) x = 2**m, where m = MINEXPONENT-DIGITS, ..., MINEXPONENT-1. Stop on the first success.
*> Mind that not all platforms might implement subnormal numbers.
*> (2) x = 2**m, where m = MINEXPONENT, ..., 0. Stop on the first success.
*> (3) x = OV, where OV is the overflow threshold. OV^2 overflows but the norm is OV.
@weslleyspereira
weslleyspereira / test_zcomplexdiv.f
Last active September 1, 2021 19:22
Test double complex division in Fortran
*> \brief zdiv tests the robustness and precision of the double complex division
*> \author Weslley S. Pereira, University of Colorado Denver, U.S.
*
*> \verbatim
*>
*> Real values for test:
*> (1) x = 2**m, where m = MINEXPONENT-DIGITS, ..., MINEXPONENT-1. Stop on the first success.
*> Mind that not all platforms might implement subnormal numbers.
*> (2) x = 2**m, where m = MINEXPONENT, ..., 0. Stop on the first success.
*> (3) x = OV, where OV is the overflow threshold. OV^2 overflows but the norm is OV.
@weslleyspereira
weslleyspereira / test_roundup_lapack.f
Last active July 27, 2021 23:43
Test routines SROUNDUP_LWORK and DROUNDUP_LWORK from https://github.com/Reference-LAPACK/lapack/pull/605
PROGRAM test_roundup
IMPLICIT NONE
INTEGER(8) X, Y
REAL SROUNDUP_LWORK
DOUBLE PRECISION DROUNDUP_LWORK
EXTERNAL SROUNDUP_LWORK, DROUNDUP_LWORK
INTRINSIC CEILING, FLOOR
// Copyright 2021 Weslley S Pereira
#include <cmath>
#include <limits>
#include <iostream>
#include <bitset>
using Integer = std::int32_t;
extern "C" {
@weslleyspereira
weslleyspereira / testSVD.f
Last active May 10, 2021 17:41
Test for Lapack DGESVDX with RANGE='I'
PROGRAM testSVD
IMPLICIT NONE
INTEGER M, N, LDA, LDU, LDVT, NS, LWORK, INFO
PARAMETER ( M = 5, N = 5, LDA = 10, LDU = 10, LDVT = 10 )
INTEGER IWORK( 12*MIN(M,N) )
DOUBLE PRECISION A( LDA, N ), S( MIN(M,N) ),
$ U( LDU, N ), VT( LDVT, N ), WORK( 2000 )
LOGICAL FUNCTION ELCTG( )
ELCTG = .TRUE.
RETURN
END
PROGRAM PROFILE_GGES3
IMPLICIT NONE
LOGICAL :: ELCTG
INTEGER :: LWORK, INFO, N, I, J, SDIM
@weslleyspereira
weslleyspereira / switchHeadphones.py
Created August 4, 2020 13:29
Tkinter toggle button to switch microphone On/Off using a script
#! /usr/bin/python
''' switchHeadphones.py
Tkinter toggle button to switch microphone On/Off using a script
Modification of the solution proposed in
https://www.daniweb.com/posts/jump/1909448
for the Mic On/Off script from
https://gist.github.com/OndraZizka/2724d353f695dacd73a50883dfdf0fc6
'''
@weslleyspereira
weslleyspereira / helloWorld.c
Created January 6, 2016 23:04
código exemplo
#include<stdio.h>
int main(){
printf("Hello World!\n");
return 0;
}