Delete unused c files

This commit is contained in:
Atsushi Togo 2021-02-22 22:32:28 +09:00
parent 5a34e48dd1
commit 6d8d5ce310
7 changed files with 0 additions and 900 deletions

View File

@ -48,10 +48,8 @@ set(SOURCES_PHONO3PY
${PROJECT_SOURCE_DIR}/c/imag_self_energy_with_g.c
${PROJECT_SOURCE_DIR}/c/interaction.c
${PROJECT_SOURCE_DIR}/c/isotope.c
${PROJECT_SOURCE_DIR}/c/kgrid.c
${PROJECT_SOURCE_DIR}/c/kpoint.c
${PROJECT_SOURCE_DIR}/c/lapack_wrapper.c
${PROJECT_SOURCE_DIR}/c/mathfunc.c
${PROJECT_SOURCE_DIR}/c/phono3py.c
${PROJECT_SOURCE_DIR}/c/phonoc_utils.c
${PROJECT_SOURCE_DIR}/c/pp_collision.c

170
c/kgrid.c
View File

@ -1,170 +0,0 @@
/* Copyright (C) 2015 Atsushi Togo */
/* All rights reserved. */
/* This file was originally part of spglib and is part of kspclib. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* * Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* * Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the */
/* distribution. */
/* * Neither the name of the phonopy project nor the names of its */
/* contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
/* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
/* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
/* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
/* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
#include <stddef.h>
#include <assert.h>
#include "kgrid.h"
static void get_all_grid_addresses(int grid_address[][3], const int mesh[3]);
static size_t get_grid_point_double_mesh(const int address_double[3],
const int mesh[3]);
static size_t get_grid_point_single_mesh(const int address[3],
const int mesh[3]);
static void modulo_i3(int v[3], const int m[3]);
static void reduce_grid_address(int address[3], const int mesh[3]);
static void reduce_grid_address_double(int address[3], const int mesh[3]);
void kgd_get_all_grid_addresses(int grid_address[][3], const int mesh[3])
{
get_all_grid_addresses(grid_address, mesh);
}
int kgd_get_grid_point_double_mesh(const int address_double[3],
const int mesh[3])
{
return get_grid_point_double_mesh(address_double, mesh);
}
size_t kgd_get_dense_grid_point_double_mesh(const int address_double[3],
const int mesh[3])
{
return get_grid_point_double_mesh(address_double, mesh);
}
void kgd_get_grid_address_double_mesh(int address_double[3],
const int address[3],
const int mesh[3],
const int is_shift[3])
{
int i;
for (i = 0; i < 3; i++) {
address_double[i] = address[i] * 2 + (is_shift[i] != 0);
}
reduce_grid_address_double(address_double, mesh);
}
static void get_all_grid_addresses(int grid_address[][3], const int mesh[3])
{
int i, j, k;
size_t grid_point;
int address[3];
for (i = 0; i < mesh[0]; i++) {
address[0] = i;
for (j = 0; j < mesh[1]; j++) {
address[1] = j;
for (k = 0; k < mesh[2]; k++) {
address[2] = k;
grid_point = get_grid_point_single_mesh(address, mesh);
assert(mesh[0] * mesh[1] * mesh[2] > grid_point);
grid_address[grid_point][0] = address[0];
grid_address[grid_point][1] = address[1];
grid_address[grid_point][2] = address[2];
reduce_grid_address(grid_address[grid_point], mesh);
}
}
}
}
static size_t get_grid_point_double_mesh(const int address_double[3],
const int mesh[3])
{
int i;
int address[3];
for (i = 0; i < 3; i++) {
if (address_double[i] % 2 == 0) {
address[i] = address_double[i] / 2;
} else {
address[i] = (address_double[i] - 1) / 2;
}
}
modulo_i3(address, mesh);
return get_grid_point_single_mesh(address, mesh);
}
static size_t get_grid_point_single_mesh(const int address[3],
const int mesh[3])
{
#ifndef GRID_ORDER_XYZ
return (address[2] * mesh[0] * (size_t)(mesh[1])
+ address[1] * mesh[0] + address[0]);
#else
return (address[0] * mesh[1] * (size_t)(mesh[2])
+ address[1] * mesh[2] + address[2]);
#endif
}
static void modulo_i3(int v[3], const int m[3])
{
int i;
for (i = 0; i < 3; i++) {
v[i] = v[i] % m[i];
if (v[i] < 0) {
v[i] += m[i];
}
}
}
static void reduce_grid_address(int address[3], const int mesh[3])
{
int i;
for (i = 0; i < 3; i++) {
#ifndef GRID_BOUNDARY_AS_NEGATIVE
address[i] -= mesh[i] * (address[i] > mesh[i] / 2);
#else
address[i] -= mesh[i] * (address[i] > (mesh[i] - 1) / 2);
#endif
}
}
static void reduce_grid_address_double(int address[3], const int mesh[3])
{
int i;
for (i = 0; i < 3; i++) {
#ifndef GRID_BOUNDARY_AS_NEGATIVE
address[i] -= 2 * mesh[i] * (address[i] > mesh[i]);
#else
address[i] -= 2 * mesh[i] * (address[i] > mesh[i] - 1);
#endif
}
}

View File

@ -1,85 +0,0 @@
/* Copyright (C) 2015 Atsushi Togo */
/* All rights reserved. */
/* This file was originally part of spglib and is part of kspclib. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* * Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* * Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the */
/* distribution. */
/* * Neither the name of the phonopy project nor the names of its */
/* contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
/* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
/* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
/* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
/* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
#ifndef __kgrid_H__
#define __kgrid_H__
#include <stddef.h>
/* #define GRID_ORDER_XYZ */
/* This changes behaviour of index order of address. */
/* Without GRID_ORDER_XYZ, left most element of address runs first. */
/* grid_address (e.g. 4x4x4 mesh, unless GRID_ORDER_XYZ is defined) */
/* [[ 0 0 0] */
/* [ 1 0 0] */
/* [ 2 0 0] */
/* [-1 0 0] */
/* [ 0 1 0] */
/* [ 1 1 0] */
/* [ 2 1 0] */
/* [-1 1 0] */
/* .... ] */
/* */
/* With GRID_ORDER_XYZ, right most element of address runs first. */
/* grid_address (e.g. 4x4x4 mesh, if GRID_ORDER_XYZ is defined) */
/* [[ 0 0 0] */
/* [ 0 0 1] */
/* [ 0 0 2] */
/* [ 0 0 -1] */
/* [ 0 1 0] */
/* [ 0 1 1] */
/* [ 0 1 2] */
/* [ 0 1 -1] */
/* .... ] */
/* #define GRID_BOUNDARY_AS_NEGATIVE */
/* This changes the behaviour of address elements on the surface of */
/* parallelepiped. */
/* For odd mesh number, this affects nothing, e.g., [-2, -1, 0, 1, 2]. */
/* regardless of with and without GRID_BOUNDARY_AS_NEGATIVE. */
/* For even mesh number, this affects as follows: */
/* without GRID_BOUNDARY_AS_NEGATIVE, e.g., [-2, -1, 0, 1, 2, 3]. */
/* with GRID_BOUNDARY_AS_NEGATIVE, e.g., [-3, -2, -1, 0, 1, 2]. */
void kgd_get_all_grid_addresses(int grid_address[][3], const int mesh[3]);
int kgd_get_grid_point_double_mesh(const int address_double[3],
const int mesh[3]);
size_t kgd_get_dense_grid_point_double_mesh(const int address_double[3],
const int mesh[3]);
void kgd_get_grid_address_double_mesh(int address_double[3],
const int address[3],
const int mesh[3],
const int is_shift[3]);
#endif

View File

@ -35,7 +35,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include "mathfunc.h"
#include "kpoint.h"
#include "rgrid.h"

View File

@ -1,518 +0,0 @@
/* Copyright (C) 2008 Atsushi Togo */
/* All rights reserved. */
/* This file is part of spglib. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* * Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* * Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the */
/* distribution. */
/* * Neither the name of the phonopy project nor the names of its */
/* contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
/* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
/* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
/* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
/* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
#include <stdio.h>
#include <stdlib.h>
#include "mathfunc.h"
#include "debug.h"
#define ZERO_PREC 1e-10
double mat_get_determinant_d3(SPGCONST double a[3][3])
{
return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1])
+ a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2])
+ a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
}
int mat_get_determinant_i3(SPGCONST int a[3][3])
{
return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1])
+ a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2])
+ a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
}
int mat_get_trace_i3( SPGCONST int a[3][3] )
{
return a[0][0] + a[1][1] + a[2][2];
}
void mat_copy_matrix_d3(double a[3][3], SPGCONST double b[3][3])
{
a[0][0] = b[0][0];
a[0][1] = b[0][1];
a[0][2] = b[0][2];
a[1][0] = b[1][0];
a[1][1] = b[1][1];
a[1][2] = b[1][2];
a[2][0] = b[2][0];
a[2][1] = b[2][1];
a[2][2] = b[2][2];
}
void mat_copy_matrix_i3(int a[3][3], SPGCONST int b[3][3])
{
a[0][0] = b[0][0];
a[0][1] = b[0][1];
a[0][2] = b[0][2];
a[1][0] = b[1][0];
a[1][1] = b[1][1];
a[1][2] = b[1][2];
a[2][0] = b[2][0];
a[2][1] = b[2][1];
a[2][2] = b[2][2];
}
void mat_copy_vector_d3(double a[3], const double b[3])
{
a[0] = b[0];
a[1] = b[1];
a[2] = b[2];
}
void mat_copy_vector_i3(int a[3], const int b[3])
{
a[0] = b[0];
a[1] = b[1];
a[2] = b[2];
}
int mat_check_identity_matrix_i3(SPGCONST int a[3][3],
SPGCONST int b[3][3])
{
if ( a[0][0] - b[0][0] ||
a[0][1] - b[0][1] ||
a[0][2] - b[0][2] ||
a[1][0] - b[1][0] ||
a[1][1] - b[1][1] ||
a[1][2] - b[1][2] ||
a[2][0] - b[2][0] ||
a[2][1] - b[2][1] ||
a[2][2] - b[2][2]) {
return 0;
}
else {
return 1;
}
}
int mat_check_identity_matrix_d3(SPGCONST double a[3][3],
SPGCONST double b[3][3],
const double symprec)
{
if ( mat_Dabs( a[0][0] - b[0][0] ) > symprec ||
mat_Dabs( a[0][1] - b[0][1] ) > symprec ||
mat_Dabs( a[0][2] - b[0][2] ) > symprec ||
mat_Dabs( a[1][0] - b[1][0] ) > symprec ||
mat_Dabs( a[1][1] - b[1][1] ) > symprec ||
mat_Dabs( a[1][2] - b[1][2] ) > symprec ||
mat_Dabs( a[2][0] - b[2][0] ) > symprec ||
mat_Dabs( a[2][1] - b[2][1] ) > symprec ||
mat_Dabs( a[2][2] - b[2][2] ) > symprec ) {
return 0;
}
else {
return 1;
}
}
int mat_check_identity_matrix_id3(SPGCONST int a[3][3],
SPGCONST double b[3][3],
const double symprec)
{
if ( mat_Dabs( a[0][0] - b[0][0] ) > symprec ||
mat_Dabs( a[0][1] - b[0][1] ) > symprec ||
mat_Dabs( a[0][2] - b[0][2] ) > symprec ||
mat_Dabs( a[1][0] - b[1][0] ) > symprec ||
mat_Dabs( a[1][1] - b[1][1] ) > symprec ||
mat_Dabs( a[1][2] - b[1][2] ) > symprec ||
mat_Dabs( a[2][0] - b[2][0] ) > symprec ||
mat_Dabs( a[2][1] - b[2][1] ) > symprec ||
mat_Dabs( a[2][2] - b[2][2] ) > symprec ) {
return 0;
}
else {
return 1;
}
}
/* m=axb */
void mat_multiply_matrix_d3(double m[3][3],
SPGCONST double a[3][3],
SPGCONST double b[3][3])
{
int i, j; /* a_ij */
double c[3][3];
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
c[i][j] =
a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
}
}
mat_copy_matrix_d3(m, c);
}
void mat_multiply_matrix_i3(int m[3][3],
SPGCONST int a[3][3],
SPGCONST int b[3][3])
{
int i, j; /* a_ij */
int c[3][3];
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
c[i][j] =
a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
}
}
mat_copy_matrix_i3(m, c);
}
void mat_multiply_matrix_di3(double m[3][3],
SPGCONST double a[3][3],
SPGCONST int b[3][3])
{
int i, j; /* a_ij */
double c[3][3];
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
c[i][j] =
a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
}
}
mat_copy_matrix_d3(m, c);
}
void mat_multiply_matrix_id3(double m[3][3],
SPGCONST int a[3][3],
SPGCONST double b[3][3])
{
int i, j; /* a_ij */
double c[3][3];
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
c[i][j] =
a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
}
}
mat_copy_matrix_d3(m, c);
}
void mat_multiply_matrix_vector_i3(int v[3],
SPGCONST int a[3][3],
const int b[3])
{
int i;
int c[3];
for (i = 0; i < 3; i++)
c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2];
for (i = 0; i < 3; i++)
v[i] = c[i];
}
void mat_multiply_matrix_vector_d3(double v[3],
SPGCONST double a[3][3],
const double b[3])
{
int i;
double c[3];
for (i = 0; i < 3; i++)
c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2];
for (i = 0; i < 3; i++)
v[i] = c[i];
}
void mat_multiply_matrix_vector_id3(double v[3],
SPGCONST int a[3][3],
const double b[3])
{
int i;
double c[3];
for (i = 0; i < 3; i++)
c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2];
for (i = 0; i < 3; i++)
v[i] = c[i];
}
void mat_multiply_matrix_vector_di3(double v[3],
SPGCONST double a[3][3],
const int b[3])
{
int i;
double c[3];
for (i = 0; i < 3; i++)
c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2];
for (i = 0; i < 3; i++)
v[i] = c[i];
}
void mat_add_matrix_i3(int m[3][3],
SPGCONST int a[3][3],
SPGCONST int b[3][3])
{
int i, j;
for ( i = 0; i < 3; i++ ) {
for ( j = 0; j < 3; j++ ) {
m[i][j] = a[i][j] + b[i][j];
}
}
}
void mat_cast_matrix_3i_to_3d(double m[3][3], SPGCONST int a[3][3])
{
m[0][0] = a[0][0];
m[0][1] = a[0][1];
m[0][2] = a[0][2];
m[1][0] = a[1][0];
m[1][1] = a[1][1];
m[1][2] = a[1][2];
m[2][0] = a[2][0];
m[2][1] = a[2][1];
m[2][2] = a[2][2];
}
void mat_cast_matrix_3d_to_3i(int m[3][3], SPGCONST double a[3][3])
{
m[0][0] = mat_Nint(a[0][0]);
m[0][1] = mat_Nint(a[0][1]);
m[0][2] = mat_Nint(a[0][2]);
m[1][0] = mat_Nint(a[1][0]);
m[1][1] = mat_Nint(a[1][1]);
m[1][2] = mat_Nint(a[1][2]);
m[2][0] = mat_Nint(a[2][0]);
m[2][1] = mat_Nint(a[2][1]);
m[2][2] = mat_Nint(a[2][2]);
}
/* m^-1 */
/* ruby code for auto generating */
/* 3.times {|i| 3.times {|j| */
/* puts "m[#{j}][#{i}]=(a[#{(i+1)%3}][#{(j+1)%3}]*a[#{(i+2)%3}][#{(j+2)%3}] */
/* -a[#{(i+1)%3}][#{(j+2)%3}]*a[#{(i+2)%3}][#{(j+1)%3}])/det;" */
/* }} */
int mat_inverse_matrix_d3(double m[3][3],
SPGCONST double a[3][3],
const double precision)
{
double det;
double c[3][3];
det = mat_get_determinant_d3(a);
if (mat_Dabs(det) < precision) {
warning_print("spglib: No inverse matrix (det=%f)\n", det);
return 0;
}
c[0][0] = (a[1][1] * a[2][2] - a[1][2] * a[2][1]) / det;
c[1][0] = (a[1][2] * a[2][0] - a[1][0] * a[2][2]) / det;
c[2][0] = (a[1][0] * a[2][1] - a[1][1] * a[2][0]) / det;
c[0][1] = (a[2][1] * a[0][2] - a[2][2] * a[0][1]) / det;
c[1][1] = (a[2][2] * a[0][0] - a[2][0] * a[0][2]) / det;
c[2][1] = (a[2][0] * a[0][1] - a[2][1] * a[0][0]) / det;
c[0][2] = (a[0][1] * a[1][2] - a[0][2] * a[1][1]) / det;
c[1][2] = (a[0][2] * a[1][0] - a[0][0] * a[1][2]) / det;
c[2][2] = (a[0][0] * a[1][1] - a[0][1] * a[1][0]) / det;
mat_copy_matrix_d3(m, c);
return 1;
}
/* m = b^-1 a b */
int mat_get_similar_matrix_d3(double m[3][3],
SPGCONST double a[3][3],
SPGCONST double b[3][3],
const double precision)
{
double c[3][3];
if (!mat_inverse_matrix_d3(c, b, precision)) {
warning_print("spglib: No similar matrix due to 0 determinant.\n");
return 0;
}
mat_multiply_matrix_d3(m, a, b);
mat_multiply_matrix_d3(m, c, m);
return 1;
}
void mat_transpose_matrix_d3(double a[3][3], SPGCONST double b[3][3])
{
double c[3][3];
c[0][0] = b[0][0];
c[0][1] = b[1][0];
c[0][2] = b[2][0];
c[1][0] = b[0][1];
c[1][1] = b[1][1];
c[1][2] = b[2][1];
c[2][0] = b[0][2];
c[2][1] = b[1][2];
c[2][2] = b[2][2];
mat_copy_matrix_d3(a, c);
}
void mat_transpose_matrix_i3(int a[3][3], SPGCONST int b[3][3])
{
int c[3][3];
c[0][0] = b[0][0];
c[0][1] = b[1][0];
c[0][2] = b[2][0];
c[1][0] = b[0][1];
c[1][1] = b[1][1];
c[1][2] = b[2][1];
c[2][0] = b[0][2];
c[2][1] = b[1][2];
c[2][2] = b[2][2];
mat_copy_matrix_i3(a, c);
}
void mat_get_metric(double metric[3][3],
SPGCONST double lattice[3][3])
{
double lattice_t[3][3];
mat_transpose_matrix_d3(lattice_t, lattice);
mat_multiply_matrix_d3(metric, lattice_t, lattice);
}
double mat_norm_squared_d3(const double a[3])
{
return a[0] * a[0] + a[1] * a[1] + a[2] * a[2];
}
int mat_norm_squared_i3(const int a[3])
{
return a[0] * a[0] + a[1] * a[1] + a[2] * a[2];
}
void mat_cross_product_d3(double v[3], const double a[3], const double b[3])
{
v[0] = a[1] * b[2] - a[2] * b[1];
v[1] = a[2] * b[0] - a[0] * b[2];
v[2] = a[0] * b[1] - a[1] * b[0];
}
double mat_Dabs(const double a)
{
if (a < 0.0)
return -a;
else
return a;
}
int mat_Nint(const double a)
{
if (a < 0.0)
return (int) (a - 0.5);
else
return (int) (a + 0.5);
}
double mat_Dmod1(const double a)
{
double b;
b = a - mat_Nint(a);
if (b < 0.0 - ZERO_PREC)
return b + 1.0;
else
return b;
}
MatINT * mat_alloc_MatINT(const int size)
{
MatINT *matint;
matint = NULL;
if ((matint = (MatINT*) malloc(sizeof(MatINT))) == NULL) {
warning_print("spglib: Memory could not be allocated.");
return NULL;
}
matint->size = size;
if (size > 0) {
if ((matint->mat = (int (*)[3][3]) malloc(sizeof(int[3][3]) * size))
== NULL) {
warning_print("spglib: Memory could not be allocated ");
warning_print("(MatINT, line %d, %s).\n", __LINE__, __FILE__);
free(matint);
matint = NULL;
return NULL;
}
}
return matint;
}
void mat_free_MatINT(MatINT * matint)
{
if (matint->size > 0) {
free(matint->mat);
matint->mat = NULL;
}
free(matint);
}
VecDBL * mat_alloc_VecDBL(const int size)
{
VecDBL *vecdbl;
vecdbl = NULL;
if ((vecdbl = (VecDBL*) malloc(sizeof(VecDBL))) == NULL) {
warning_print("spglib: Memory could not be allocated.");
return NULL;
}
vecdbl->size = size;
if (size > 0) {
if ((vecdbl->vec = (double (*)[3]) malloc(sizeof(double[3]) * size))
== NULL) {
warning_print("spglib: Memory could not be allocated ");
warning_print("(VecDBL, line %d, %s).\n", __LINE__, __FILE__);
free(vecdbl);
vecdbl = NULL;
return NULL;
}
}
return vecdbl;
}
void mat_free_VecDBL(VecDBL * vecdbl)
{
if (vecdbl->size > 0) {
free(vecdbl->vec);
vecdbl->vec = NULL;
}
free(vecdbl);
}
int mat_is_int_matrix(SPGCONST double mat[3][3], const double symprec)
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
if (mat_Dabs(mat_Nint(mat[i][j]) - mat[i][j]) > symprec) {
return 0;
}
}
}
return 1;
}

View File

@ -1,123 +0,0 @@
/* Copyright (C) 2008 Atsushi Togo */
/* All rights reserved. */
/* This file is part of spglib. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* * Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* * Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the */
/* distribution. */
/* * Neither the name of the phonopy project nor the names of its */
/* contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
/* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
/* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
/* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
/* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
#ifndef __mathfunc_H__
#define __mathfunc_H__
#ifndef SPGCONST
#define SPGCONST
#endif
typedef struct {
int size;
int (*mat)[3][3];
} MatINT;
typedef struct {
int size;
double (*vec)[3];
} VecDBL;
double mat_get_determinant_d3(SPGCONST double a[3][3]);
int mat_get_determinant_i3(SPGCONST int a[3][3]);
int mat_get_trace_i3(SPGCONST int a[3][3]);
void mat_copy_matrix_d3(double a[3][3], SPGCONST double b[3][3]);
void mat_copy_matrix_i3(int a[3][3], SPGCONST int b[3][3]);
void mat_copy_vector_d3(double a[3], const double b[3]);
void mat_copy_vector_i3(int a[3], const int b[3]);
int mat_check_identity_matrix_i3(SPGCONST int a[3][3],
SPGCONST int b[3][3]);
int mat_check_identity_matrix_d3(SPGCONST double a[3][3],
SPGCONST double b[3][3],
const double symprec);
int mat_check_identity_matrix_id3(SPGCONST int a[3][3],
SPGCONST double b[3][3],
const double symprec);
void mat_multiply_matrix_d3(double m[3][3],
SPGCONST double a[3][3],
SPGCONST double b[3][3]);
void mat_multiply_matrix_i3(int m[3][3],
SPGCONST int a[3][3],
SPGCONST int b[3][3]);
void mat_multiply_matrix_di3(double m[3][3],
SPGCONST double a[3][3],
SPGCONST int b[3][3]);
void mat_multiply_matrix_id3( double m[3][3],
SPGCONST int a[3][3],
SPGCONST double b[3][3]);
void mat_multiply_matrix_vector_i3(int v[3],
SPGCONST int a[3][3],
const int b[3]);
void mat_multiply_matrix_vector_d3(double v[3],
SPGCONST double a[3][3],
const double b[3]);
void mat_multiply_matrix_vector_id3(double v[3],
SPGCONST int a[3][3],
const double b[3]);
void mat_multiply_matrix_vector_di3(double v[3],
SPGCONST double a[3][3],
const int b[3]);
void mat_add_matrix_i3(int m[3][3],
SPGCONST int a[3][3],
SPGCONST int b[3][3]);
void mat_cast_matrix_3i_to_3d(double m[3][3],
SPGCONST int a[3][3]);
void mat_cast_matrix_3d_to_3i(int m[3][3],
SPGCONST double a[3][3]);
int mat_inverse_matrix_d3(double m[3][3],
SPGCONST double a[3][3],
const double precision);
int mat_get_similar_matrix_d3(double m[3][3],
SPGCONST double a[3][3],
SPGCONST double b[3][3],
const double precision);
void mat_transpose_matrix_d3(double a[3][3],
SPGCONST double b[3][3]);
void mat_transpose_matrix_i3(int a[3][3],
SPGCONST int b[3][3]);
void mat_get_metric(double metric[3][3],
SPGCONST double lattice[3][3]);
double mat_norm_squared_d3(const double a[3]);
int mat_norm_squared_i3(const int a[3]);
void mat_cross_product_d3(double v[3], const double a[3], const double b[3]);
double mat_Dabs(const double a);
int mat_Nint(const double a);
double mat_Dmod1(const double a);
MatINT * mat_alloc_MatINT(const int size);
void mat_free_MatINT(MatINT * matint);
VecDBL * mat_alloc_VecDBL(const int size);
void mat_free_VecDBL(VecDBL * vecdbl);
int mat_is_int_matrix(SPGCONST double mat[3][3], const double symprec);
#endif

View File

@ -212,7 +212,6 @@ sources_phono3py = ['c/_phono3py.c',
'c/imag_self_energy_with_g.c',
'c/interaction.c',
'c/isotope.c',
'c/kgrid.c',
'c/kpoint.c',
'c/lapack_wrapper.c',
'c/mathfunc.c',