I have that question of how it works if
in low level programming.
If so, it checks the RAM by going through all the addresses that contain it.
I have that question of how it works if
in low level programming.
If so, it checks the RAM by going through all the addresses that contain it.
I have a doubt in wolfram mathematica
. What happens is that I have an array of data and I can generate a espectrograma
, what I need is to generate this same spectrogram in 3 dimensions,
2D spectrogram
3D spectrogram (what I want to obtain)
What I want is to achieve something like in the following image
I have achieved it with files .WAV
but not with an excel column with data, which I import into mathematica, I only managed to apply filters and do the spectrograma
2D. If someone could give me some help I would appreciate it. Thank you very much.
Edit (I'll add what I have regarding the doubt)
I am using the code that is in the following link, but I think I do not understand the input parameters for the function well, I cannot get it to work for the .csv file . It is probable that I am doing everything wrong and this is not the function that I should use, I have also tried with ListPointPlot3D without results (I can only graph the spectrogram in 2D), but here they import a .WAV file
https://mathematica.stackexchange.com/questions/4017/computing-and-plotting-a-spectrogram-in-mathematica
Attached is the link of the noise.scv file (file of values separated by commas) which is the one I need to graph
https://mega.nz/#!P912VDIT!cRuug34tTVqFO41bc4hhepLfxk4jV5mYCJjwfeTYvLI
And finally the lines of code to import the file to Wolfram
datosExcel = Import["C:\\ruta_del_archivo.csv"]
datosExcel = datosExcel[[All, 1]]
I am trying to alphabetize a variable of type array in the following way:
Code
$palabras = array(
'así',
'alfabeto',
'alfabético',
'año',
);
sort($palabras);
var_export($palabras);
Result
array (
0 => 'alfabeto',
1 => 'alfabético',
2 => 'así',
3 => 'año',
)
But as you can see, it doesn't work correctly with the accents and the "ñ", which should be sorted as if the accents weren't there, and with "n" < "ñ" < "o"
.
How can I do to sort them alphabetically without using external libraries?
I just did a commit:
git commit -m "este es un comentario"
However, I have suddenly realized that this message is not correct. Can I modify it? If yes, how?
If I write again git commit -m "un nuevo comentario"
it will make another commit instead of modifying the one I already did.
Here is a very peculiar piece of C++ code. For some strange reason sorting the data miraculously causes the code to run 3 times faster.
#include <algorithm>
#include <ctime>
#include <iostream>
int main()
{
// Generate data
const unsigned arraySize = 32768;
int data[arraySize];
for (unsigned c = 0; c < arraySize; ++c)
data[c] = std::rand() % 256;
// !!! Con esto el siguiente bucle se ejecuta más rápido.
std::sort(data, data + arraySize);
// Test
clock_t start = clock();
long long sum = 0;
for (unsigned i = 0; i < 100000; ++i)
{
// Primary loop
for (unsigned c = 0; c < arraySize; ++c)
{
if (data[c] >= 128)
sum += data[c];
}
}
double elapsedTime = static_cast<double>(clock() - start) / CLOCKS_PER_SEC;
std::cout << elapsedTime << std::endl;
std::cout << "sum = " << sum << std::endl;
}
std::sort(data, data + arraySize);
, the code runs in 12.41 seconds.At first I thought it might be a language or compiler anomaly. So I tried in Java :
import java.util.Arrays;
import java.util.Random;
public class Main
{
public static void main(String[] args)
{
// Generate data
int arraySize = 32768;
int data[] = new int[arraySize];
Random rnd = new Random(0);
for (int c = 0; c < arraySize; ++c)
data[c] = rnd.nextInt() % 256;
// !!! Con esto el siguiente bucle se ejecuta más rápido.
Arrays.sort(data);
// Test
long start = System.nanoTime();
long sum = 0;
for (int i = 0; i < 100000; ++i)
{
// Primary loop
for (int c = 0; c < arraySize; ++c)
{
if (data[c] >= 128)
sum += data[c];
}
}
System.out.println((System.nanoTime() - start) / 1000000000.0);
System.out.println("sum = " + sum);
}
}
Which gives similar but less extreme results. 10.7 and 6.2 seconds.
At first I thought it might have to do with sorting the data getting it into the cache, and then I realized that the data had just been generated with what should already be in the cache before sorting.
This is a question translated from the original in English and adapted to the results it gives on my computer: Why is processing a sorted array faster than an unsorted array? by GManNickG