Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision fba30097ae6ca68f2e397f176863fb3d3edd301c authored by Jonas on 04 October 2023, 14:52:00 UTC, committed by Jonas on 04 October 2023, 14:52:00 UTC
Add ref HAL
1 parent 384285f
  • Files
  • Changes
  • e3f3ace
  • /
  • sosnoise.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:fba30097ae6ca68f2e397f176863fb3d3edd301c
directory badge Iframe embedding
swh:1:dir:e3f3acea5a45c0d74eaf0a13999938556f69e5d5
content badge Iframe embedding
swh:1:cnt:2f121f705a9692bc74f24febe206af240f6e0760

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
sosnoise.py
from numba import njit
from math import cos, exp, sin, pi
from random import gauss, seed, uniform
from common import vec2, vec4
from numpy import empty, dot

dir = []

def init_noise_vectors(N):
	'''Initialize random vectors used to generate the 2D sine waves that form the basis of the noise'''
	# The sum-of-sines noise depends on random vectors. This seed has been observed to work 
	# well as the basis of the noise function that we use to produce the curl noise
	seed(25)
	global dir
	dir = empty((N,4))
	sigma = 7
	for i in range(N):
		alpha = uniform(0, 2*pi)
		w = gauss(mu=0,sigma=sigma)
		v_2d = vec2(cos(alpha), sin(alpha))*(sigma+w)
		v = vec4(v_2d[0], v_2d[1],exp(-w*w/sigma**2), uniform(0,2*pi))
		dir[i] = v

init_noise_vectors(256)

@njit
def sos_noise(x):
	'''Noise function. Simply sums a number of sine functions'''
	I = 0.0
	for d in dir:
		I += sin(dot(x,d[0:2])+d[3])*d[2]
	return 0.5 + 0.5 * (I / float(len(dir)))

@njit
def sos_noise_grad(p):
	x = p[0:2]
	'''Gradient of noise function computed analytically'''
	g = vec2(0,0)
	for d in dir:
		g += d[2]*d[0:2]*cos(dot(x,d[0:2])+d[3])
	return 0.5 * g / len(dir)	
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API