Skip to content
Snippets Groups Projects
Commit d4513a26 authored by Chichi Lalescu's avatar Chichi Lalescu
Browse files

switch endianness manually for p3DFFT_to_iR

thank you Stephen for the btle() function.
parent 82125ea2
No related branches found
No related tags found
No related merge requests found
...@@ -438,6 +438,31 @@ int field_descriptor::interleave( ...@@ -438,6 +438,31 @@ int field_descriptor::interleave(
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
int field_descriptor::switch_endianness(
float *a)
{
for (int i = 0; i < this->local_size; i++)
{
*a = btle(*a);
a++;
}
return EXIT_SUCCESS;
}
int field_descriptor::switch_endianness(
fftwf_complex *b)
{
float *a = (float*)b;
for (int i = 0; i < this->local_size; i++)
{
*a = btle(*a);
a++;
*a = btle(*a);
a++;
}
return EXIT_SUCCESS;
}
field_descriptor* field_descriptor::get_transpose() field_descriptor* field_descriptor::get_transpose()
{ {
int n[this->ndims]; int n[this->ndims];
......
...@@ -84,6 +84,11 @@ class field_descriptor ...@@ -84,6 +84,11 @@ class field_descriptor
int interleave( int interleave(
fftwf_complex *input, fftwf_complex *input,
int dim); int dim);
int switch_endianness(
float *a);
int switch_endianness(
fftwf_complex *a);
}; };
......
...@@ -130,6 +130,8 @@ int p3DFFT_to_iR::read( ...@@ -130,6 +130,8 @@ int p3DFFT_to_iR::read(
this->f0c->read( this->f0c->read(
ifile[i], ifile[i],
(void*)(this->c3 + i*this->f3c->local_size)); (void*)(this->c3 + i*this->f3c->local_size));
this->f0c->switch_endianness(
(this->c3 + i*this->f3c->local_size));
DEBUG_MSG("p3DFFT_to_iR::read " DEBUG_MSG("p3DFFT_to_iR::read "
"this->f0c->transpose(...);\n"); "this->f0c->transpose(...);\n");
this->f0c->transpose( this->f0c->transpose(
......
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:966c6344a3d90cdf5a7423c96eebbfd82f41bd0e6556fcce769383cb4e93116c" "signature": "sha256:48849ce7df2009ce7253f1b242366c1e998f76ecec705fb62d3af98ecbe8bbc0"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
...@@ -57,22 +57,14 @@ ...@@ -57,22 +57,14 @@
"Kdata0 = generate_data_3D(n, p = 2).astype(np.complex64)\n", "Kdata0 = generate_data_3D(n, p = 2).astype(np.complex64)\n",
"Kdata1 = generate_data_3D(n, p = 2).astype(np.complex64)\n", "Kdata1 = generate_data_3D(n, p = 2).astype(np.complex64)\n",
"Kdata2 = generate_data_3D(n, p = 2).astype(np.complex64)\n", "Kdata2 = generate_data_3D(n, p = 2).astype(np.complex64)\n",
"Kdata0.T.copy().astype('<c8').tofile(\"Kdata0\")\n", "Kdata0.T.copy().astype('>c8').tofile(\"Kdata0\")\n",
"Kdata1.T.copy().astype('<c8').tofile(\"Kdata1\")\n", "Kdata1.T.copy().astype('>c8').tofile(\"Kdata1\")\n",
"Kdata2.T.copy().astype('<c8').tofile(\"Kdata2\")" "Kdata2.T.copy().astype('>c8').tofile(\"Kdata2\")"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{ "prompt_number": 7
"output_type": "stream",
"stream": "stderr",
"text": [
"-c:15: RuntimeWarning: divide by zero encountered in true_divide\n"
]
}
],
"prompt_number": 2
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -155,7 +147,7 @@ ...@@ -155,7 +147,7 @@
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"prompt_number": 3 "prompt_number": 8
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -208,7 +200,7 @@ ...@@ -208,7 +200,7 @@
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"prompt_number": 5 "prompt_number": 15
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -249,11 +241,11 @@ ...@@ -249,11 +241,11 @@
"text": [ "text": [
"0.0\n", "0.0\n",
"distance is small\n", "distance is small\n",
"14.4104\n" "15.2714\n"
] ]
} }
], ],
"prompt_number": 6 "prompt_number": 16
}, },
{ {
"cell_type": "code", "cell_type": "code",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment