code
stringlengths
3
1.01M
repo_name
stringlengths
5
116
path
stringlengths
3
311
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
3
1.01M
class Lsof < Formula desc "Utility to list open files" homepage "https://people.freebsd.org/~abe/" url "https://github.com/lsof-org/lsof/archive/4.94.0.tar.gz" sha256 "a9865eeb581c3abaac7426962ddb112ecfd86a5ae93086eb4581ce100f8fa8f4" license "Zlib" bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "3202f83509eefa73603b865ea4aca0433bbbf69d30f43d229a5ee256d1977424" sha256 cellar: :any_skip_relocation, big_sur: "7dbab0c2a35d97381ed52fa32e1507c0fe83bc405fc40c4d00c79e12c79cffe4" sha256 cellar: :any_skip_relocation, catalina: "58d2ee9a7484541a7280f5a139f2d0454b494f54bca3b9f10273e036d8071bde" sha256 cellar: :any_skip_relocation, mojave: "9eb185a83e641bd8bd90fab3a8cde572b23ebb1ce269a8832fb85a66c5037318" sha256 cellar: :any_skip_relocation, high_sierra: "268fe15ecc8d9e4dd4f2f45737c921e54a5aa999f15ab6b724b9bd34deeef8d1" end keg_only :provided_by_macos def install os = "linux" on_macos do ENV["LSOF_INCLUDE"] = "#{MacOS.sdk_path}/usr/include" # Source hardcodes full header paths at /usr/include inreplace %w[ dialects/darwin/kmem/dlsof.h dialects/darwin/kmem/machine.h dialects/darwin/libproc/machine.h ], "/usr/include", "#{MacOS.sdk_path}/usr/include" os = "darwin" end ENV["LSOF_CC"] = ENV.cc ENV["LSOF_CCV"] = ENV.cxx mv "00README", "README" system "./Configure", "-n", os system "make" bin.install "lsof" man8.install "Lsof.8" end test do (testpath/"test").open("w") do system "#{bin}/lsof", testpath/"test" end end end
JCount/homebrew-core
Formula/lsof.rb
Ruby
bsd-2-clause
1,621
<div class="modal fade" id="add_query_dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" ng-disabled="saveInProgress" aria-hidden="true">&times;</button> <h4 class="modal-title">Add Widget</h4> </div> <div class="modal-body"> <p class="btn-group"> <button type="button" class="btn btn-default" ng-class="{active: isVisualization()}" ng-click="setType('visualization')">Visualization</button> <button type="button" class="btn btn-default" ng-class="{active: isTextBox()}" ng-click="setType('textbox')">Text Box</button> </p> <div ng-show="isTextBox()"> <div class="form-group"> <textarea class="form-control" ng-model="text" rows="3"></textarea> </div> <div ng-show="text"> <strong>Preview:</strong> <p ng-bind-html="text | markdown"></p> </div> </div> <div ng-show="isVisualization()"> <div class="form-group"> <ui-select ng-model="query.selected" theme="bootstrap" reset-search-input="false"> <ui-select-match placeholder="Search a query by name">{{$select.selected.name}}</ui-select-match> <ui-select-choices repeat="q in queries" refresh="searchQueries($select.search)" refresh-delay="0"> <div ng-bind-html="q.name | highlight: $select.search | trustAsHtml"></div> </ui-select-choices> </ui-select> </div> <div ng-show="selected_query"> <div class="form-group"> <label for="">Choose Visualization</label> <select ng-model="selectedVis" ng-options="vis as vis.name group by vis.type for vis in selected_query.visualizations" class="form-control"></select> </div> </div> </div> <div class="form-group"> <label for="">Widget Size</label> <select class="form-control" ng-model="widgetSize" ng-options="c.value as c.name for c in widgetSizes"></select> </div> <div class="checkbox"> <label title="Show table empty or filled."> <input type="checkbox" ng-model="showAlways"> Show Always </label> </div> <div class="checkbox"> <label title="Include this widget on the export or not."> <input type="checkbox" ng-model="exportable.isExportable"> Include this widget on the export </label> </div> <div ng-if="query.selected !== undefined && exportable.isExportable" class="form-group" ng-if="exportable.isExportable"> <label for="">Worksheet label for exporting widget</label> <input type="text" class="form-control" ng-model="exportable.name"> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" ng-disabled="saveInProgress" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary" ng-disabled="saveInProgress || !(selectedVis || isTextBox())" ng-click="saveWidget()">Add to Dashboard</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div>
jmvasquez/redashtest
rd_ui/app/views/new_widget_form.html
HTML
bsd-2-clause
3,996
cask "font-rasa" do version :latest sha256 :no_check url "https://github.com/google/fonts/trunk/ofl/rasa", verified: "github.com/google/fonts/", using: :svn, trust_cert: true name "Rasa" homepage "https://fonts.google.com/specimen/Rasa" font "Rasa-Bold.ttf" font "Rasa-Light.ttf" font "Rasa-Medium.ttf" font "Rasa-Regular.ttf" font "Rasa-SemiBold.ttf" end
alerque/homebrew-fonts
Casks/font-rasa.rb
Ruby
bsd-2-clause
403
import sympy.core.cache # Why doesn't it work to use "import sympy.core.compatibility" and call "with_metaclass" as "sympy.core.compatibility.with_metaclass"? from sympy.core.compatibility import with_metaclass from sympy.core.function import AppliedUndef, FunctionClass from sympy.core.core import BasicMeta from sympy.core.assumptions import ManagedProperties from sympy.core.cache import cacheit ''' Tensor('name') creates a tensor that does not take arguments >>> T = Tensor('T') >>> T(*index) TensorFunction creates a teonsr that do take arguments >>> TF = TensorFunction('TF') >>> TF(*index)(*args) Both Tensor and TensorFuncton takes any number of index. Anytning can be put as an index but only indices of type sympy.Dummy or sympy.Symbol will be contracted over in varios functions. >>> a=sympy.Dymmy('a'); b=sympy.Dymmy('b') >>> isinstance(Tensor('T')(a,b), sympy.Symbol) True >>> a=sympy.Dymmy('a'); b=sympy.Dymmy('b') >>> isinstance(TensorFunction('TF')(a,b), sympy.FunctionClass) True >>> a=sympy.Dymmy('a'); b=sympy.Dummy('b); >>> x=sympy.Symbol('x') >>> isinstance(TensorFunction('TF')(a,b)(x), sympy.Function) True ''' def isTensor(exp): '''Test if exp is a Tensor or TensorFunction. Only returns True for Tensor with index/indecis and TensorFunction with index/indecis and argument(s) Only test the top type of exp, e.g. does not detect a derivative of a tensor as a tensor''' return (isinstance(exp,(AppliedTensor, AppliedAppliedTensorFunction))) def tensorName(exp): '''Writes exp a sring as a sring, without indices, without arguments.''' if isinstance(exp,AppliedTensor): return type(exp).__name__ if isinstance(type(exp),AppliedTensorFunction): return type(type(exp)).__name__ if hasattr(exp,'args'): return type(exp).__name__ return str(exp) def longTensorName(exp): '''Writes exp a sring as a sring, without indices, with arguments.''' if isinstance(exp,AppliedTensor): return type(exp).__name__ if isinstance(type(exp),AppliedTensorFunction): return (type(type(exp)).__name__ + "(" + ", ".join([longTensorName(arg) for arg in exp.args]) + ")" ) if getattr(exp, 'args', []): return (type(exp).__name__ + "(" + ", ".join([longTensorName(arg) for arg in exp.args]) + ")" ) return str(exp) # Defines what types of indices that can be contracted over def isAllowedDummyIndex(ind): '''Returns True if object is allowed to use as a dummy index to be summed over acording to Einsteins sumation convention''' return isinstance(ind, (sympy.Symbol, sympy.Dummy) ) def withNewIndex(tensor,index): if isTensor(tensor): return tensor.withNewIndex(*index) return tensor class TensorFunction(BasicMeta): @cacheit def __new__(mcl, name, *arg, **kw): if (name == "AppliedTensorFunction"): return type.__new__(mcl, name, *arg, **kw) return type.__new__(mcl, name, (AppliedTensorFunction,), kw) def __init__(self, *arg, **kw): pass #FIXME use sympy.core.compatibility.with_metaclass or similar class AppliedTensorFunction(FunctionClass): __metaclass__ = TensorFunction @cacheit def __new__(mcl, *index, **kw): name = mcl.__name__ + str(index) ret = type.__new__(mcl, name, (AppliedAppliedTensorFunction,AppliedUndef),kw) ret.index = index return ret is_Tensor = True class AppliedAppliedTensorFunction(AppliedUndef): def withNewIndex(self, *index): return type(type(self))(*index)(*self.args) class Tensor(ManagedProperties): @cacheit def __new__(mcl, name, *arg, **kw): if (name == "AppliedTensor"): return type.__new__(mcl, name, *arg, **kw) return type.__new__(mcl, name, (AppliedTensor,),kw) #FIXME use sympy.core.compatibility.with_metaclass or class AppliedTensor(sympy.Symbol): __metaclass__ = Tensor @cacheit def __new__(cls, *index, **kw): name = cls.__name__ + str(index) ret = sympy.Symbol.__new__(cls, name, **kw) ret.index = index return ret is_Tensor = True def withNewIndex(self,*index): return type(self)(*index) ##################### Here be unittest ##################### import unittest class TestTensor(unittest.TestCase): def setUp(self): self.t = Tensor('t') self.T = Tensor('t') self.tf = TensorFunction('tf') self.TF = TensorFunction('tf') self.a = sympy.Dummy('a') self.b = sympy.Dummy('b') self.x = sympy.Symbol('x') self.f = sympy.Function('f') def test_classRelations(self): t=self.t; tf=self.tf; a=self.a; b=self.b; x=self.x self.assertEqual( type(t), Tensor ) self.assertEqual( type(t(a,b)), t ) self.assertEqual( type(t(a,b)).__base__, AppliedTensor ) self.assertTrue( isinstance(t(a,b), sympy.Symbol)) self.assertEqual( type(tf(a,b)), tf ) self.assertEqual( type(tf(a,b)).__base__, AppliedTensorFunction ) self.assertTrue( isinstance(tf(a,b), sympy.FunctionClass) ) self.assertEqual( type(tf(a,b)(x)), tf(a,b) ) self.assertEqual( type(tf(a,b)(x)).__base__, AppliedAppliedTensorFunction ) self.assertTrue( isinstance(tf(a,b)(x), AppliedUndef) ) self.assertTrue( isinstance(tf(a,b)(x), sympy.Function) ) def test_withNewIndex(self): t=self.t; tf=self.tf; a=self.a; b=self.b; x=self.x self.assertEqual( t(a).withNewIndex(b,b), t(b,b) ) self.assertEqual( tf(a)(x).withNewIndex(b,b), tf(b,b)(x) ) def test_isTensor(self): t=self.t; tf=self.tf; a=self.a; b=self.b; x=self.x; f=self.f self.assertFalse( isTensor(a) ) self.assertFalse( isTensor(f(x)) ) self.assertTrue( isTensor(t(a,b)) ) self.assertTrue( isTensor(tf(a,b)(x,x)) ) def test_eqality(self): t=self.t; tf=self.tf; a=self.a; b=self.b; x=self.x; TF=self.TF; T=self.T self.assertEqual( t(a), T(a) ) self.assertNotEqual( t(b), t(a) ) self.assertEqual( tf(a)(x,b), TF(a)(x,b) ) self.assertNotEqual( tf(a)(x,b), tf(a)(x,x) ) self.assertNotEqual( tf(a)(x,b), tf(b)(x,b) ) if __name__ == '__main__': unittest.main()
LindaLinsefors/EinSumConv
EinSumConv/tensor.py
Python
bsd-2-clause
6,432
/** * @file log.c Logging * * Copyright (C) 2010 Creytiv.com */ #include <re.h> #include <restund.h> static struct { struct list logl; bool debug; bool stder; } lg = { .logl = LIST_INIT, .debug = false, .stder = true }; void restund_log_register_handler(struct restund_log *log) { if (!log) return; list_append(&lg.logl, &log->le, log); } void restund_log_unregister_handler(struct restund_log *log) { if (!log) return; list_unlink(&log->le); } void restund_log_enable_debug(bool enable) { lg.debug = enable; } void restund_log_enable_stderr(bool enable) { lg.stder = enable; } void restund_vlog(uint32_t level, const char *fmt, va_list ap) { char buf[4096]; struct le *le; if (re_vsnprintf(buf, sizeof(buf), fmt, ap) < 0) return; if (lg.stder) (void)re_fprintf(stderr, "%s", buf); le = lg.logl.head; while (le) { struct restund_log *log = le->data; le = le->next; if (log->h) log->h(level, buf); } } void restund_log(uint32_t level, const char *fmt, ...) { va_list ap; if ((RESTUND_DEBUG == level) && !lg.debug) return; va_start(ap, fmt); restund_vlog(level, fmt, ap); va_end(ap); } void restund_debug(const char *fmt, ...) { va_list ap; if (!lg.debug) return; va_start(ap, fmt); restund_vlog(RESTUND_DEBUG, fmt, ap); va_end(ap); } void restund_info(const char *fmt, ...) { va_list ap; va_start(ap, fmt); restund_vlog(RESTUND_INFO, fmt, ap); va_end(ap); } void restund_warning(const char *fmt, ...) { va_list ap; va_start(ap, fmt); restund_vlog(RESTUND_WARNING, fmt, ap); va_end(ap); } void restund_error(const char *fmt, ...) { va_list ap; va_start(ap, fmt); restund_vlog(RESTUND_ERROR, fmt, ap); va_end(ap); }
ph4r05/restund
src/log.c
C
bsd-2-clause
1,718
<?php // Load init.php require(dirname(__FILE__).'/init.php'); // Return a Response instance return new Response(new Headers(), new Cookies()); ?>
Falc/Aluminium
aluminium/components/response/instance.php
PHP
bsd-2-clause
150
using System.Diagnostics; using Xamarin.Forms; using Xamarin.Forms.Platform.UWP; [assembly: ExportRenderer(typeof(WebView), typeof(HikingPathFinder.App.UWP.UwpWebViewRenderer))] namespace HikingPathFinder.App.UWP { /// <summary> /// UWP custom WebView renderer /// See https://xamarinhelp.com/webview-rendering-engine-configuration/ /// </summary> public class UwpWebViewRenderer : WebViewRenderer { /// <summary> /// Called when web view element has been changed /// </summary> /// <param name="args">event args for web view change</param> protected override void OnElementChanged(ElementChangedEventArgs<WebView> args) { base.OnElementChanged(args); if (args.NewElement != null && this.Control != null) { this.SetupWebViewSettings(); } } /// <summary> /// Sets up settings for WebView element /// </summary> private void SetupWebViewSettings() { this.Control.Settings.IsJavaScriptEnabled = true; this.Control.ScriptNotify += this.OnScriptNotify; } /// <summary> /// Called when window.script.notify has been called from JavaScript /// </summary> /// <param name="sender">sender object</param> /// <param name="args">event args</param> private void OnScriptNotify(object sender, Windows.UI.Xaml.Controls.NotifyEventArgs args) { Debug.WriteLine( string.Format( "ScriptNotify: {0}, CallingUri={1}, Value={2}", sender.ToString(), args.CallingUri, args.Value)); } } }
vividos/HikingPathFinder
src/Frontend/App/UWP/UwpWebViewRenderer.cs
C#
bsd-2-clause
1,782
# # Sending emails in combination # with Motion surveillance software # # (c) Dr. Yves J. Hilpisch # The Python Quants GmbH # import smtplib from datetime import datetime from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText def prompt(prompt): return raw_input(prompt).strip() fromaddr = 'rpi@hilpisch.com' # prompt("From: ") toaddrs = 'yves@hilpisch.com' # prompt("To: ") subject = 'Security Alert.' # prompt("Subject: ") msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddrs msg['Subject'] = subject # Add the From: and To: headers at the start! # msg = ("From: %s\r\nTo: %s\r\n\r\nSubject: %s\r\n" # % (fromaddr, ", ".join(toaddrs), subject)) # print "Enter message, end with ^D (Unix) or ^Z (Windows):" # body = '' #while 1: # try: # line = raw_input() # except EOFError: # break # if not line: # break # body = body + line body = 'A motion has been detected.\nTime: %s' % str(datetime.now()) msg.attach(MIMEText(body, 'plain')) print "Message length is " + repr(len(msg)) smtp = smtplib.SMTP() # smtp.starttls() smtp.set_debuglevel(1) smtp.connect('smtp.hilpisch.com', 587) smtp.login('hilpisch13', 'henrynikolaus06') text = msg.as_string() smtp.sendmail(fromaddr, toaddrs, text) smtp.quit() print text
yhilpisch/rpi
doc/_store/mail.py
Python
bsd-2-clause
1,304
package org.laladev.moneyjinn.server.controller.report; import java.sql.Date; import java.time.LocalDate; import java.time.Month; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.inject.Inject; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.laladev.moneyjinn.core.rest.model.ErrorResponse; import org.laladev.moneyjinn.core.rest.model.report.ShowTrendsGraphRequest; import org.laladev.moneyjinn.core.rest.model.report.ShowTrendsGraphResponse; import org.laladev.moneyjinn.core.rest.model.report.transport.TrendsCalculatedTransport; import org.laladev.moneyjinn.core.rest.model.report.transport.TrendsSettledTransport; import org.laladev.moneyjinn.model.access.GroupID; import org.laladev.moneyjinn.model.access.UserID; import org.laladev.moneyjinn.model.capitalsource.Capitalsource; import org.laladev.moneyjinn.model.capitalsource.CapitalsourceID; import org.laladev.moneyjinn.server.builder.CapitalsourceTransportBuilder; import org.laladev.moneyjinn.server.builder.GroupTransportBuilder; import org.laladev.moneyjinn.server.builder.TrendsTransportBuilder; import org.laladev.moneyjinn.server.builder.UserTransportBuilder; import org.laladev.moneyjinn.server.controller.AbstractControllerTest; import org.laladev.moneyjinn.service.api.ICapitalsourceService; import org.springframework.http.HttpMethod; import org.springframework.test.context.jdbc.Sql; public class ShowTrendsGraphTest extends AbstractControllerTest { @Inject private ICapitalsourceService capitalsourceService; private final HttpMethod method = HttpMethod.PUT; private String userName; private String userPassword; @BeforeEach public void setUp() { this.userName = UserTransportBuilder.USER1_NAME; this.userPassword = UserTransportBuilder.USER1_PASSWORD; } @Override protected String getUsername() { return this.userName; } @Override protected String getPassword() { return this.userPassword; } @Override protected String getUsecase() { return super.getUsecaseFromTestClassName(this.getClass()); } @SuppressWarnings("deprecation") @Test public void test_maxDateRange_response() throws Exception { final ShowTrendsGraphRequest request = new ShowTrendsGraphRequest(); request.setStartDate(new Date(70, 0, 1)); request.setEndDate(new Date(199, 11, 31)); request.setCapitalSourceIds(Arrays.asList(CapitalsourceTransportBuilder.CAPITALSOURCE1_ID, CapitalsourceTransportBuilder.CAPITALSOURCE2_ID, CapitalsourceTransportBuilder.CAPITALSOURCE3_ID, CapitalsourceTransportBuilder.CAPITALSOURCE4_ID)); final ShowTrendsGraphResponse expected = new ShowTrendsGraphResponse(); final List<TrendsSettledTransport> trendsSettledTransports = new ArrayList<>(); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2008).withMonth(11).withAmount("1099.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2008).withMonth(12).withAmount("1110.00") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(1).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(2).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(3).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(4).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(5).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(6).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(7).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(8).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(9).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(10).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(11).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(12).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2010).withMonth(1).withAmount("108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2010).withMonth(2).withAmount("118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2010).withMonth(3).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2010).withMonth(4).withAmount("1110.00") .build(TrendsSettledTransport.class)); expected.setTrendsSettledTransports(trendsSettledTransports); final List<TrendsCalculatedTransport> trendsCalculatedTransports = new ArrayList<>(); trendsCalculatedTransports.add(new TrendsTransportBuilder().withYear(2010).withMonth(5).withAmount("1100.00") .build(TrendsCalculatedTransport.class)); expected.setTrendsCalculatedTransports(trendsCalculatedTransports); final ShowTrendsGraphResponse actual = super.callUsecaseWithContent("", this.method, request, false, ShowTrendsGraphResponse.class); Assertions.assertEquals(expected, actual); } @SuppressWarnings("deprecation") @Test public void test_only2009_response() throws Exception { final ShowTrendsGraphRequest request = new ShowTrendsGraphRequest(); request.setStartDate(new Date(109, 0, 1)); request.setEndDate(new Date(109, 11, 31)); request.setCapitalSourceIds(Arrays.asList(CapitalsourceTransportBuilder.CAPITALSOURCE1_ID, CapitalsourceTransportBuilder.CAPITALSOURCE2_ID, CapitalsourceTransportBuilder.CAPITALSOURCE3_ID, CapitalsourceTransportBuilder.CAPITALSOURCE4_ID)); final ShowTrendsGraphResponse expected = new ShowTrendsGraphResponse(); final List<TrendsSettledTransport> trendsSettledTransports = new ArrayList<>(); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(1).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(2).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(3).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(4).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(5).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(6).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(7).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(8).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(9).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(10).withAmount("1118.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(11).withAmount("1108.90") .build(TrendsSettledTransport.class)); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2009).withMonth(12).withAmount("1118.90") .build(TrendsSettledTransport.class)); expected.setTrendsSettledTransports(trendsSettledTransports); final ShowTrendsGraphResponse actual = super.callUsecaseWithContent("", this.method, request, false, ShowTrendsGraphResponse.class); Assertions.assertEquals(expected, actual); } @SuppressWarnings("deprecation") @Test public void test_onlyOneUnsettledMonth_response() throws Exception { final ShowTrendsGraphRequest request = new ShowTrendsGraphRequest(); request.setStartDate(new Date(110, 4, 1)); request.setEndDate(new Date(110, 11, 31)); request.setCapitalSourceIds(Arrays.asList(CapitalsourceTransportBuilder.CAPITALSOURCE1_ID, CapitalsourceTransportBuilder.CAPITALSOURCE2_ID, CapitalsourceTransportBuilder.CAPITALSOURCE3_ID, CapitalsourceTransportBuilder.CAPITALSOURCE4_ID)); final ShowTrendsGraphResponse expected = new ShowTrendsGraphResponse(); final List<TrendsCalculatedTransport> trendsCalculatedTransports = new ArrayList<>(); trendsCalculatedTransports.add(new TrendsTransportBuilder().withYear(2010).withMonth(5).withAmount("-10.00") .build(TrendsCalculatedTransport.class)); expected.setTrendsCalculatedTransports(trendsCalculatedTransports); final ShowTrendsGraphResponse actual = super.callUsecaseWithContent("", this.method, request, false, ShowTrendsGraphResponse.class); Assertions.assertEquals(expected, actual); } @SuppressWarnings("deprecation") @Test public void test_validtyPeriodOfCapitalsource_response() throws Exception { final CapitalsourceID capitalsourceId = new CapitalsourceID(CapitalsourceTransportBuilder.CAPITALSOURCE4_ID); final UserID userId = new UserID(UserTransportBuilder.USER3_ID); final GroupID groupId = new GroupID(GroupTransportBuilder.GROUP1_ID); final Capitalsource capitalsource = this.capitalsourceService.getCapitalsourceById(userId, groupId, capitalsourceId); capitalsource.setValidTil(LocalDate.of(2010, Month.APRIL, 30)); this.capitalsourceService.updateCapitalsource(capitalsource); final ShowTrendsGraphRequest request = new ShowTrendsGraphRequest(); request.setStartDate(new Date(110, 3, 1)); request.setEndDate(new Date(110, 11, 31)); request.setCapitalSourceIds(Arrays.asList(CapitalsourceTransportBuilder.CAPITALSOURCE4_ID)); final ShowTrendsGraphResponse expected = new ShowTrendsGraphResponse(); final List<TrendsSettledTransport> trendsSettledTransports = new ArrayList<>(); trendsSettledTransports.add(new TrendsTransportBuilder().withYear(2010).withMonth(4).withAmount("1000.00") .build(TrendsSettledTransport.class)); expected.setTrendsSettledTransports(trendsSettledTransports); final ShowTrendsGraphResponse actual = super.callUsecaseWithContent("", this.method, request, false, ShowTrendsGraphResponse.class); Assertions.assertEquals(expected, actual); } @Test public void test_AuthorizationRequired_Error() throws Exception { this.userName = null; this.userPassword = null; final ErrorResponse actual = super.callUsecaseWithoutContent("", this.method, false, ErrorResponse.class); Assertions.assertEquals(super.accessDeniedErrorResponse(), actual); } @Test @Sql("classpath:h2defaults.sql") public void test_emptyDatabase_noException() throws Exception { this.userName = UserTransportBuilder.ADMIN_NAME; this.userPassword = UserTransportBuilder.ADMIN_PASSWORD; final ShowTrendsGraphRequest request = new ShowTrendsGraphRequest(); super.callUsecaseWithContent("", this.method, request, false, ShowTrendsGraphResponse.class); } @SuppressWarnings("deprecation") @Test @Sql("classpath:h2defaults.sql") public void test_emptyDatabaseFakeRequestData_noException() throws Exception { this.userName = UserTransportBuilder.ADMIN_NAME; this.userPassword = UserTransportBuilder.ADMIN_PASSWORD; final ShowTrendsGraphRequest request = new ShowTrendsGraphRequest(); request.setStartDate(new Date(110, 3, 1)); request.setEndDate(new Date(110, 11, 31)); request.setCapitalSourceIds(Arrays.asList(CapitalsourceTransportBuilder.CAPITALSOURCE4_ID)); super.callUsecaseWithContent("", this.method, request, false, ShowTrendsGraphResponse.class); } }
OlliL/moneyjinn-server
moneyjinn-server/src/test/java/org/laladev/moneyjinn/server/controller/report/ShowTrendsGraphTest.java
Java
bsd-2-clause
12,714
from actstream.models import Action from django.test import TestCase from cyidentity.cyfullcontact.tests.util import create_sample_contact_info class FullContactActivityStreamTestCase(TestCase): def test_contact_create(self): contact_info = create_sample_contact_info() action = Action.objects.actor(contact_info).latest('timestamp') self.assertEqual(action.verb, 'FullContact information was created')
shawnhermans/cyborgcrm
cyidentity/cyfullcontact/tests/test_activity_stream.py
Python
bsd-2-clause
433
#!/usr/bin/env ruby # Basic File Inclusion #class String #def vowels #self.scan(/[aeiou]/i) #end #end require './string_extension' puts "This is a sentencE".vowels.join('-') require_relative 'string_extension' puts "This is a sentencE".vowels.join('-')
sharkspeed/dororis
languages/ruby/beginning-ruby/7-chapter/1-projects.rb
Ruby
bsd-2-clause
273
/*** * \file InversePerspectiveMapping.cc * \author Mohamed Aly <malaa@caltech.edu> * \date 11/29/2006 */ #include "InversePerspectiveMapping.hh" #include "CameraInfoOpt.h" #include <iostream> #include <math.h> #include <assert.h> #include <list> using namespace std; #include <cv.h> #include <highgui.h> namespace LaneDetector { #define VP_PORTION 0.05 /* We are assuming the world coordinate frame center is at the camera, the ground plane is at height -h, the X-axis is going right, the Y-axis is going forward, the Z-axis is going up. The camera is looking forward with optical axis in direction of Y-axis, with possible pitch angle (above or below the Y-axis) and yaw angle (left or right). The camera coordinates have the same center as the world, but the Xc-axis goes right, the Yc-axis goes down, and the Zc-axis (optical cxis) goes forward. The uv-plane of the image is such that u is horizontal going right, v is vertical going down. The image coordinates uv are such that the pixels are at half coordinates i.e. first pixel is (.5,.5) ...etc where the top-left point is (0,0) i.e. the tip of the first pixel is (0,0) */ /** * This function returns the Inverse Perspective Mapping * of the input image, assuming a flat ground plane, and * given the camera parameters. * * \param inImage the input image * \param outImage the output image in IPM * \param ipmInfo the returned IPM info for the transformation * \param focalLength focal length (in x and y direction) * \param cameraInfo the camera parameters * \param outPoints indices of points outside the image */ void mcvGetIPM(const CvMat* inImage, CvMat* outImage, IPMInfo *ipmInfo, const CameraInfo *cameraInfo, list<CvPoint> *outPoints) { //check input images types //CvMat inMat, outMat; //cvGetMat(inImage, &inMat); //cvGetMat(outImage, &outMat); //cout << CV_MAT_TYPE(inImage->type) << " " << CV_MAT_TYPE(FLOAT_MAT_TYPE) << " " << CV_MAT_TYPE(INT_MAT_TYPE)<<"\n"; if (!(CV_ARE_TYPES_EQ(inImage, outImage) && (CV_MAT_TYPE(inImage->type)==CV_MAT_TYPE(FLOAT_MAT_TYPE) || (CV_MAT_TYPE(inImage->type)==CV_MAT_TYPE(INT_MAT_TYPE))))) { cerr << "Unsupported image types in mcvGetIPM"; exit(1); } //get size of input image FLOAT u, v; v = inImage->height; u = inImage->width; //get the vanishing point FLOAT_POINT2D vp; vp = mcvGetVanishingPoint(cameraInfo); vp.y = MAX(0, vp.y); //vp.y = 30; //get extent of the image in the xfyf plane FLOAT_MAT_ELEM_TYPE eps = ipmInfo->vpPortion * v;//VP_PORTION*v; ipmInfo->ipmLeft = MAX(0, ipmInfo->ipmLeft); ipmInfo->ipmRight = MIN(u-1, ipmInfo->ipmRight); ipmInfo->ipmTop = MAX(vp.y+eps, ipmInfo->ipmTop); ipmInfo->ipmBottom = MIN(v-1, ipmInfo->ipmBottom); FLOAT_MAT_ELEM_TYPE uvLimitsp[] = {vp.x, ipmInfo->ipmRight, ipmInfo->ipmLeft, vp.x, ipmInfo->ipmTop, ipmInfo->ipmTop, ipmInfo->ipmTop, ipmInfo->ipmBottom}; //{vp.x, u, 0, vp.x, //vp.y+eps, vp.y+eps, vp.y+eps, v}; CvMat uvLimits = cvMat(2, 4, FLOAT_MAT_TYPE, uvLimitsp); /* // **** Debug ***** // print camera info printf("\nCamera info\n"); printf("Yaw: %f\n",cameraInfo->yaw); printf("Pitch: %f\n",cameraInfo->pitch); printf("Focal Length x: %f\n",cameraInfo->focalLength.x); printf("Focal Length y: %f\n",cameraInfo->focalLength.y); printf("Optical Center x: %f\n",cameraInfo->opticalCenter.x); printf("Optical Center y: %f\n",cameraInfo->opticalCenter.y); printf("Camera Heigth: %f\n",cameraInfo->cameraHeight); printf("Vanishing point x: %f\n",vp.x); printf("Vanishing point y: %f\n",vp.y); // **** Debug ***** // print IPM info printf("\nIPM info\n"); printf("VP Portion: %f\n",ipmInfo->vpPortion); printf("IPM Left: %f\n",ipmInfo->ipmLeft); printf("IPM Right: %f\n",ipmInfo->ipmRight); printf("IPM Top: %f\n",ipmInfo->ipmTop); printf("IPM Bottom: %f\n",ipmInfo->ipmBottom); //printf("\nImage Frame: uvLimits\n"); //printf("%f\t%f\t%f\t%f\t\n",uvLimitsp[0],uvLimitsp[1],uvLimitsp[2],uvLimitsp[3]); //printf("%f\t%f\t%f\t%f\t\n",uvLimitsp[4],uvLimitsp[5],uvLimitsp[6],uvLimitsp[7]); SHOW_MAT(&uvLimits, "uvLImits"); CvMat* debugDisp = cvCloneMat(inImage); CvPoint test = CvPoint(int(vp.x),int(ipmInfo->ipmRight)); //cvCircle(debugDisp, CvPoint(int(vp.x),int(ipmInfo->ipmTop)), 3, CV_RGB(255,255,0), 1,8,0); cvCircle(debugDisp, CvPoint(int(ipmInfo->ipmRight),int(ipmInfo->ipmTop)), 3, CV_RGB(255,255,0), 1,8,0); cvCircle(debugDisp, CvPoint(int(ipmInfo->ipmLeft),int(ipmInfo->ipmTop)), 3, CV_RGB(255,255,0), 1,8,0); cvCircle(debugDisp, CvPoint(int(vp.x),int(ipmInfo->ipmBottom)), 3, CV_RGB(255,255,0), 1,8,0); //cvCircle(debugDisp, CvPoint(int(vp.x),int(vp.y)), 3, CV_RGB(255,255,0), 1,8,0); SHOW_IMAGE(debugDisp,"uvLimits",10); char key = cvWaitKey(0); */ //get these points on the ground plane CvMat * xyLimitsp = cvCreateMat(2, 4, FLOAT_MAT_TYPE); CvMat xyLimits = *xyLimitsp; mcvTransformImage2Ground(&uvLimits, &xyLimits,cameraInfo); //SHOW_MAT(xyLimitsp, "xyLImits"); //get extent on the ground plane CvMat row1, row2; cvGetRow(&xyLimits, &row1, 0); cvGetRow(&xyLimits, &row2, 1); double xfMax, xfMin, yfMax, yfMin; cvMinMaxLoc(&row1, (double*)&xfMin, (double*)&xfMax, 0, 0, 0); cvMinMaxLoc(&row2, (double*)&yfMin, (double*)&yfMax, 0, 0, 0); INT outRow = outImage->height; INT outCol = outImage->width; FLOAT_MAT_ELEM_TYPE stepRow = (yfMax-yfMin)/outRow; FLOAT_MAT_ELEM_TYPE stepCol = (xfMax-xfMin)/outCol; //construct the grid to sample CvMat *xyGrid = cvCreateMat(2, outRow*outCol, FLOAT_MAT_TYPE); INT i, j; FLOAT_MAT_ELEM_TYPE x, y; //fill it with x-y values on the ground plane in world frame for (i=0, y=yfMax-.5*stepRow; i<outRow; i++, y-=stepRow) for (j=0, x=xfMin+.5*stepCol; j<outCol; j++, x+=stepCol) { CV_MAT_ELEM(*xyGrid, FLOAT_MAT_ELEM_TYPE, 0, i*outCol+j) = x; CV_MAT_ELEM(*xyGrid, FLOAT_MAT_ELEM_TYPE, 1, i*outCol+j) = y; } //get their pixel values in image frame CvMat *uvGrid = cvCreateMat(2, outRow*outCol, FLOAT_MAT_TYPE); mcvTransformGround2Image(xyGrid, uvGrid, cameraInfo); //now loop and find the nearest pixel value for each position //that's inside the image, otherwise put it zero FLOAT_MAT_ELEM_TYPE ui, vi; //get mean of the input image CvScalar means = cvAvg(inImage); double mean = means.val[0]; //generic loop to work for both float and int matrix types #define MCV_GET_IPM(type) \ for (i=0; i<outRow; i++) \ for (j=0; j<outCol; j++) \ { \ /*get pixel coordiantes*/ \ ui = CV_MAT_ELEM(*uvGrid, FLOAT_MAT_ELEM_TYPE, 0, i*outCol+j); \ vi = CV_MAT_ELEM(*uvGrid, FLOAT_MAT_ELEM_TYPE, 1, i*outCol+j); \ /*check if out-of-bounds*/ \ /*if (ui<0 || ui>u-1 || vi<0 || vi>v-1) \*/ \ if (ui<ipmInfo->ipmLeft || ui>ipmInfo->ipmRight || \ vi<ipmInfo->ipmTop || vi>ipmInfo->ipmBottom) \ { \ CV_MAT_ELEM(*outImage, type, i, j) = (type)mean; \ } \ /*not out of bounds, then get nearest neighbor*/ \ else \ { \ /*Bilinear interpolation*/ \ if (ipmInfo->ipmInterpolation == 0) \ { \ int x1 = int(ui), x2 = int(ui+1); \ int y1 = int(vi), y2 = int(vi+1); \ float x = ui - x1, y = vi - y1; \ float val = CV_MAT_ELEM(*inImage, type, y1, x1) * (1-x) * (1-y) + \ CV_MAT_ELEM(*inImage, type, y1, x2) * x * (1-y) + \ CV_MAT_ELEM(*inImage, type, y2, x1) * (1-x) * y + \ CV_MAT_ELEM(*inImage, type, y2, x2) * x * y; \ CV_MAT_ELEM(*outImage, type, i, j) = (type)val; \ } \ /*nearest-neighbor interpolation*/ \ else \ CV_MAT_ELEM(*outImage, type, i, j) = \ CV_MAT_ELEM(*inImage, type, int(vi+.5), int(ui+.5)); \ } \ if (outPoints && \ (ui<ipmInfo->ipmLeft+10 || ui>ipmInfo->ipmRight-10 || \ vi<ipmInfo->ipmTop || vi>ipmInfo->ipmBottom-2) )\ outPoints->push_back(cvPoint(j, i)); \ } if (CV_MAT_TYPE(inImage->type)==FLOAT_MAT_TYPE) { MCV_GET_IPM(FLOAT_MAT_ELEM_TYPE) } else { MCV_GET_IPM(INT_MAT_ELEM_TYPE) } //return the ipm info ipmInfo->xLimits[0] = CV_MAT_ELEM(*xyGrid, FLOAT_MAT_ELEM_TYPE, 0, 0); ipmInfo->xLimits[1] = CV_MAT_ELEM(*xyGrid, FLOAT_MAT_ELEM_TYPE, 0, (outRow-1)*outCol+outCol-1); ipmInfo->yLimits[1] = CV_MAT_ELEM(*xyGrid, FLOAT_MAT_ELEM_TYPE, 1, 0); ipmInfo->yLimits[0] = CV_MAT_ELEM(*xyGrid, FLOAT_MAT_ELEM_TYPE, 1, (outRow-1)*outCol+outCol-1); ipmInfo->xScale = 1/stepCol; ipmInfo->yScale = 1/stepRow; ipmInfo->width = outCol; ipmInfo->height = outRow; //clean cvReleaseMat(&xyLimitsp); cvReleaseMat(&xyGrid); cvReleaseMat(&uvGrid); } /** * Transforms points from the image frame (uv-coordinates) * into the real world frame on the ground plane (z=-height) * * \param inPoints input points in the image frame * \param outPoints output points in the world frame on the ground * (z=-height) * \param cemaraInfo the input camera parameters * */ void mcvTransformImage2Ground(const CvMat *inPoints, CvMat *outPoints, const CameraInfo *cameraInfo) { //add two rows to the input points CvMat *inPoints4 = cvCreateMat(inPoints->rows+2, inPoints->cols, cvGetElemType(inPoints)); //copy inPoints to first two rows CvMat inPoints2, inPoints3, inPointsr4, inPointsr3; cvGetRows(inPoints4, &inPoints2, 0, 2); cvGetRows(inPoints4, &inPoints3, 0, 3); cvGetRow(inPoints4, &inPointsr3, 2); cvGetRow(inPoints4, &inPointsr4, 3); cvSet(&inPointsr3, cvRealScalar(1)); cvCopy(inPoints, &inPoints2); //create the transformation matrix float c1 = cos(cameraInfo->pitch); float s1 = sin(cameraInfo->pitch); float c2 = cos(cameraInfo->yaw); float s2 = sin(cameraInfo->yaw); float matp[] = { -cameraInfo->cameraHeight*c2/cameraInfo->focalLength.x, cameraInfo->cameraHeight*s1*s2/cameraInfo->focalLength.y, (cameraInfo->cameraHeight*c2*cameraInfo->opticalCenter.x/ cameraInfo->focalLength.x)- (cameraInfo->cameraHeight *s1*s2* cameraInfo->opticalCenter.y/ cameraInfo->focalLength.y) - cameraInfo->cameraHeight *c1*s2, cameraInfo->cameraHeight *s2 /cameraInfo->focalLength.x, cameraInfo->cameraHeight *s1*c2 /cameraInfo->focalLength.y, (-cameraInfo->cameraHeight *s2* cameraInfo->opticalCenter.x /cameraInfo->focalLength.x)-(cameraInfo->cameraHeight *s1*c2* cameraInfo->opticalCenter.y /cameraInfo->focalLength.y) - cameraInfo->cameraHeight *c1*c2, 0, cameraInfo->cameraHeight *c1 /cameraInfo->focalLength.y, (-cameraInfo->cameraHeight *c1* cameraInfo->opticalCenter.y / cameraInfo->focalLength.y) + cameraInfo->cameraHeight *s1, 0, -c1 /cameraInfo->focalLength.y, (c1* cameraInfo->opticalCenter.y /cameraInfo->focalLength.y) - s1, }; CvMat mat = cvMat(4, 3, CV_32FC1, matp); //multiply cvMatMul(&mat, &inPoints3, inPoints4); //divide by last row of inPoints4 for (int i=0; i<inPoints->cols; i++) { float div = CV_MAT_ELEM(inPointsr4, float, 0, i); CV_MAT_ELEM(*inPoints4, float, 0, i) = CV_MAT_ELEM(*inPoints4, float, 0, i) / div ; CV_MAT_ELEM(*inPoints4, float, 1, i) = CV_MAT_ELEM(*inPoints4, float, 1, i) / div; } //put back the result into outPoints cvCopy(&inPoints2, outPoints); //clear cvReleaseMat(&inPoints4); } /** * Transforms points from the ground plane (z=-h) in the world frame * into points on the image in image frame (uv-coordinates) * * \param inPoints 2xN array of input points on the ground in world coordinates * \param outPoints 2xN output points in on the image in image coordinates * \param cameraInfo the camera parameters * */ void mcvTransformGround2Image(const CvMat *inPoints, CvMat *outPoints, const CameraInfo *cameraInfo) { //add two rows to the input points CvMat *inPoints3 = cvCreateMat(inPoints->rows+1, inPoints->cols, cvGetElemType(inPoints)); //copy inPoints to first two rows CvMat inPoints2, inPointsr3; cvGetRows(inPoints3, &inPoints2, 0, 2); cvGetRow(inPoints3, &inPointsr3, 2); cvSet(&inPointsr3, cvRealScalar(-cameraInfo->cameraHeight)); cvCopy(inPoints, &inPoints2); //create the transformation matrix float c1 = cos(cameraInfo->pitch); float s1 = sin(cameraInfo->pitch); float c2 = cos(cameraInfo->yaw); float s2 = sin(cameraInfo->yaw); float matp[] = { cameraInfo->focalLength.x * c2 + c1*s2* cameraInfo->opticalCenter.x, -cameraInfo->focalLength.x * s2 + c1*c2* cameraInfo->opticalCenter.x, - s1 * cameraInfo->opticalCenter.x, s2 * (-cameraInfo->focalLength.y * s1 + c1* cameraInfo->opticalCenter.y), c2 * (-cameraInfo->focalLength.y * s1 + c1* cameraInfo->opticalCenter.y), -cameraInfo->focalLength.y * c1 - s1* cameraInfo->opticalCenter.y, c1*s2, c1*c2, -s1 }; CvMat mat = cvMat(3, 3, CV_32FC1, matp); //multiply cvMatMul(&mat, inPoints3, inPoints3); //divide by last row of inPoints4 for (int i=0; i<inPoints->cols; i++) { float div = CV_MAT_ELEM(inPointsr3, float, 0, i); CV_MAT_ELEM(*inPoints3, float, 0, i) = CV_MAT_ELEM(*inPoints3, float, 0, i) / div ; CV_MAT_ELEM(*inPoints3, float, 1, i) = CV_MAT_ELEM(*inPoints3, float, 1, i) / div; } //put back the result into outPoints cvCopy(&inPoints2, outPoints); //clear cvReleaseMat(&inPoints3); } /** * Computes the vanishing point in the image plane uv. It is * the point of intersection of the image plane with the line * in the XY-plane in the world coordinates that makes an * angle yaw clockwise (form Y-axis) with Y-axis * * \param cameraInfo the input camera parameter * * \return the computed vanishing point in image frame * */ FLOAT_POINT2D mcvGetVanishingPoint(const CameraInfo *cameraInfo) { //get the vp in world coordinates FLOAT_MAT_ELEM_TYPE vpp[] = {sin(cameraInfo->yaw)/cos(cameraInfo->pitch), cos(cameraInfo->yaw)/cos(cameraInfo->pitch), 0}; CvMat vp = cvMat(3, 1, FLOAT_MAT_TYPE, vpp); //transform from world to camera coordinates // //rotation matrix for yaw FLOAT_MAT_ELEM_TYPE tyawp[] = {cos(cameraInfo->yaw), -sin(cameraInfo->yaw), 0, sin(cameraInfo->yaw), cos(cameraInfo->yaw), 0, 0, 0, 1}; CvMat tyaw = cvMat(3, 3, FLOAT_MAT_TYPE, tyawp); //rotation matrix for pitch FLOAT_MAT_ELEM_TYPE tpitchp[] = {1, 0, 0, 0, -sin(cameraInfo->pitch), -cos(cameraInfo->pitch), 0, cos(cameraInfo->pitch), -sin(cameraInfo->pitch)}; CvMat transform = cvMat(3, 3, FLOAT_MAT_TYPE, tpitchp); //combined transform cvMatMul(&transform, &tyaw, &transform); // //transformation from (xc, yc) in camra coordinates // to (u,v) in image frame // //matrix to shift optical center and focal length FLOAT_MAT_ELEM_TYPE t1p[] = { cameraInfo->focalLength.x, 0, cameraInfo->opticalCenter.x, 0, cameraInfo->focalLength.y, cameraInfo->opticalCenter.y, 0, 0, 1}; CvMat t1 = cvMat(3, 3, FLOAT_MAT_TYPE, t1p); //combine transform cvMatMul(&t1, &transform, &transform); //transform cvMatMul(&transform, &vp, &vp); // //clean and return // FLOAT_POINT2D ret; ret.x = cvGetReal1D(&vp, 0); ret.y = cvGetReal1D(&vp, 1); return ret; } /** * Converts a point from IPM pixel coordinates into world coordinates * * \param point in/out point * \param ipmInfo the ipm info from mcvGetIPM * */ void mcvPointImIPM2World(FLOAT_POINT2D *point, const IPMInfo *ipmInfo) { //x-direction point->x /= ipmInfo->xScale; point->x += ipmInfo->xLimits[0]; //y-direction point->y /= ipmInfo->yScale; point->y = ipmInfo->yLimits[1] - point->y; } /** * Converts from IPM pixel coordinates into world coordinates * * \param inMat input matrix 2xN * \param outMat output matrix 2xN * \param ipmInfo the ipm info from mcvGetIPM * */ void mcvTransformImIPM2Ground(const CvMat *inMat, CvMat* outMat, const IPMInfo *ipmInfo) { CvMat *mat; mat = outMat; if(inMat != mat) { cvCopy(inMat, mat); } //work on the x-direction i.e. first row CvMat row; cvGetRow(mat, &row, 0); cvConvertScale(&row, &row, 1./ipmInfo->xScale, ipmInfo->xLimits[0]); //work on y-direction cvGetRow(mat, &row, 1); cvConvertScale(&row, &row, -1./ipmInfo->yScale, ipmInfo->yLimits[1]); } /** * Converts from IPM pixel coordinates into Image coordinates * * \param inMat input matrix 2xN * \param outMat output matrix 2xN * \param ipmInfo the ipm info from mcvGetIPM * \param cameraInfo the camera info * */ void mcvTransformImIPM2Im(const CvMat *inMat, CvMat* outMat, const IPMInfo *ipmInfo, const CameraInfo *cameraInfo) { //convert to world coordinates mcvTransformImIPM2Ground(inMat, outMat, ipmInfo); //convert to image coordinates mcvTransformGround2Image(outMat, outMat, cameraInfo); } /** * Initializes the cameraInfo structure with data read from the conf file * * \param fileName the input camera conf file name * \param cameraInfo the returned camera parametrs struct * */ void mcvInitCameraInfo (char * const fileName, CameraInfo *cameraInfo) { //parsed camera data CameraInfoParserInfo camInfo; //read the data assert(cameraInfoParser_configfile(fileName, &camInfo, 0, 1, 1)==0); //init the strucure cameraInfo->focalLength.x = camInfo.focalLengthX_arg; cameraInfo->focalLength.y = camInfo.focalLengthY_arg; cameraInfo->opticalCenter.x = camInfo.opticalCenterX_arg; cameraInfo->opticalCenter.y = camInfo.opticalCenterY_arg; cameraInfo->cameraHeight = camInfo.cameraHeight_arg; cameraInfo->pitch = camInfo.pitch_arg * CV_PI/180; cameraInfo->yaw = camInfo.yaw_arg * CV_PI/180; cameraInfo->imageWidth = camInfo.imageWidth_arg; cameraInfo->imageHeight = camInfo.imageHeight_arg; } /** * Scales the cameraInfo according to the input image size * * \param cameraInfo the input/return structure * \param size the input image size * */ void mcvScaleCameraInfo (CameraInfo *cameraInfo, CvSize size) { //compute the scale factor double scaleX = size.width/cameraInfo->imageWidth; double scaleY = size.height/cameraInfo->imageHeight; //scale cameraInfo->imageWidth = size.width; cameraInfo->imageHeight = size.height; cameraInfo->focalLength.x *= scaleX; cameraInfo->focalLength.y *= scaleY; cameraInfo->opticalCenter.x *= scaleX; cameraInfo->opticalCenter.y *= scaleY; } /** * Gets the extent of the image on the ground plane given the camera parameters * * \param cameraInfo the input camera info * \param ipmInfo the IPM info containing the extent on ground plane: * xLimits & yLimits only are changed * */ void mcvGetIPMExtent(const CameraInfo *cameraInfo, IPMInfo *ipmInfo ) { //get size of input image FLOAT u, v; v = cameraInfo->imageHeight; u = cameraInfo->imageWidth; //get the vanishing point FLOAT_POINT2D vp; vp = mcvGetVanishingPoint(cameraInfo); vp.y = MAX(0, vp.y); //get extent of the image in the xfyf plane FLOAT_MAT_ELEM_TYPE eps = VP_PORTION*v; FLOAT_MAT_ELEM_TYPE uvLimitsp[] = {vp.x, u, 0, vp.x, vp.y+eps, vp.y+eps, vp.y+eps, v}; CvMat uvLimits = cvMat(2, 4, FLOAT_MAT_TYPE, uvLimitsp); //get these points on the ground plane CvMat * xyLimitsp = cvCreateMat(2, 4, FLOAT_MAT_TYPE); CvMat xyLimits = *xyLimitsp; mcvTransformImage2Ground(&uvLimits, &xyLimits,cameraInfo); //SHOW_MAT(xyLimitsp, "xyLImits"); //get extent on the ground plane CvMat row1, row2; cvGetRow(&xyLimits, &row1, 0); cvGetRow(&xyLimits, &row2, 1); double xfMax, xfMin, yfMax, yfMin; cvMinMaxLoc(&row1, (double*)&xfMin, (double*)&xfMax, 0, 0, 0); cvMinMaxLoc(&row2, (double*)&yfMin, (double*)&yfMax, 0, 0, 0); //return ipmInfo->xLimits[0] = xfMin; ipmInfo->xLimits[1] = xfMax; ipmInfo->yLimits[1] = yfMax; ipmInfo->yLimits[0] = yfMin; } } // namespace LaneDetector
rajnikant1010/EVAutomation
computer_vision/focus_lane_detection/InversePerspectiveMapping.cc
C++
bsd-2-clause
20,248
/* Strike by Appiphony Version: 1.0.0 Website: http://www.lightningstrike.io GitHub: https://github.com/appiphony/Strike-Components License: BSD 3-Clause License */ ({ afterRender: function(component, helper) { this.superAfterRender(); helper.selectRadioButtonFromValue(component, helper); } }) /* Copyright 2017 Appiphony, LLC Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holder 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. */
appiphony/Strike-Components
aura/strike_radioGroup/strike_radioGroupRenderer.js
JavaScript
bsd-2-clause
1,789
//================================================================================================= /*! // \file blaze/math/constraints/DeclHermExpr.h // \brief Constraint on the data type // // Copyright (C) 2012-2017 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. 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. // 3. Neither the names of the Blaze development group 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 _BLAZE_MATH_CONSTRAINTS_DECLHERMEXPR_H_ #define _BLAZE_MATH_CONSTRAINTS_DECLHERMEXPR_H_ //************************************************************************************************* // Includes //************************************************************************************************* #include <blaze/math/typetraits/IsDeclHermExpr.h> namespace blaze { //================================================================================================= // // MUST_BE_DECLHERMEXPR_TYPE CONSTRAINT // //================================================================================================= //************************************************************************************************* /*!\brief Constraint on the data type. // \ingroup math_constraints // // In case the given data type \a T is not a declherm expression (i.e. a type derived from the // DeclHermExpr base class), a compilation error is created. */ #define BLAZE_CONSTRAINT_MUST_BE_DECLHERMEXPR_TYPE(T) \ static_assert( ::blaze::IsDeclHermExpr<T>::value, "Non-declherm expression type detected" ) //************************************************************************************************* //================================================================================================= // // MUST_NOT_BE_DECLHERMEXPR_TYPE CONSTRAINT // //================================================================================================= //************************************************************************************************* /*!\brief Constraint on the data type. // \ingroup math_constraints // // In case the given data type \a T is a declherm expression (i.e. a type derived from the // DeclHermExpr base class), a compilation error is created. */ #define BLAZE_CONSTRAINT_MUST_NOT_BE_DECLHERMEXPR_TYPE(T) \ static_assert( !::blaze::IsDeclHermExpr<T>::value, "Declherm expression type detected" ) //************************************************************************************************* } // namespace blaze #endif
Kolkir/blaze-nn
third-party/blaze/include/blaze/math/constraints/DeclHermExpr.h
C
bsd-2-clause
4,114
class Ldc < Formula desc "Portable D programming language compiler" homepage "http://wiki.dlang.org/LDC" url "https://github.com/ldc-developers/ldc/releases/download/v0.17.0/ldc-0.17.0-src.tar.gz" sha256 "6c80086174ca87281413d7510641caf99dc630e6cf228a619d0d989bbf53bdd2" head "https://github.com/ldc-developers/ldc.git", :shallow => false bottle do sha256 "c2ff6360645d4deb2ec135b262d257e85228df95e7765adb9e3a625b76250923" => :el_capitan sha256 "551a58a74107f93620af10964ef3128642ae4575ad2be31c618935ced420cd47" => :yosemite sha256 "6d9d60e0a1711a12e03729f273459363873286ce77977801cfbbfc517fc7af1a" => :mavericks end needs :cxx11 depends_on "cmake" => :build depends_on "llvm" => :build depends_on "libconfig" def install # Fix the error: # CMakeFiles/LDCShared.dir/build.make:68: recipe for target 'dmd2/id.h' failed ENV.deparallelize if OS.linux? ENV.cxx11 mkdir "build" cd "build" do system "cmake", "..", "-DINCLUDE_INSTALL_DIR=#{include}/dlang/ldc", *std_cmake_args system "make" system "make", "install" end end test do (testpath/"test.d").write <<-EOS.undent import std.stdio; void main() { writeln("Hello, world!"); } EOS system "#{bin}/ldc2", "test.d" system "./test" system "#{bin}/ldmd2", "test.d" system "./test" end end
ebouaziz/linuxbrew
Library/Formula/ldc.rb
Ruby
bsd-2-clause
1,379
var EIDSS = { BvMessages: { 'bntHideSearch': 'Hide Search', 'bntShowSearch': 'Show Search', 'btnClear': 'Clear the field contents', 'btnHideErrDetail': 'Hide Details', 'btnSelect': 'Select', 'btnShowErrDetail': 'Show Details', 'btnView': 'View', 'strSave_Id': 'Save', 'tooltipSave_Id': 'Save', 'strClose_Id': 'Close', 'strRefresh_Id': 'Refresh', 'tooltipRefresh_Id': 'Refresh', 'strCreate_Id': 'New', 'tooltipCreate_Id': 'New', 'strEdit_Id': 'Edit', 'tooltipEdit_Id': 'Edit', 'Confirmation': 'Confirmation', 'Delete Record': 'Delete Record', 'ErrAuthentication': 'The request requires user authentication.', 'ErrDatabase': 'Error during database operation.', 'errDatabaseNotFound': 'Cannot open database \'{0}\' on server \'{1}\'. Check the correctness of database name.', 'ErrDataValidation': 'Some field contains invalid data.', 'ErrEmptyUserLogin': 'User login can\'t be empty', 'ErrFieldSampleIDNotFound': 'Sample is not found.', 'ErrFillDataset': 'Error during retrieving data from database.', 'ErrFilterValidatioError': 'Filter criteria value for [{0}] field can\'t be empty.', 'errGeneralNetworkError': 'Can\'t establish connection to the SQL Server. Please check that network connection is established and try to open this form again.', 'ErrIncorrectDatabaseVersion': 'The database version is absent or in incorrect format. Please upgrade your database to latest database version.', 'errInvailidSiteID': 'Invalid Site ID or Serial Number', 'errInvailidSiteType': 'Invalid Site Type or Serial Number', 'ErrInvalidFieldFormat': 'Invalid data format for field \'{0}\'.', 'ErrInvalidLogin': 'Cannot connect to SQL server. The database user name or password is not correct.', 'ErrInvalidParameter': 'Invalid value passed to the sql command parameter.', 'errInvalidSearchCriteria': 'Invalid search criteria.', 'ErrLocalFieldSampleIDNotFound': 'Local/field sample ID is not found in the grid.', 'ErrLoginIsLocked': 'You have exceeded the number of incorrect login attempts. Please try again in {0} minutes.', 'ErrLowClientVersion': 'The application version doesn\'t correspond to database version. Please install the latest application version.', 'ErrLowDatabaseVersion': 'The application requires the newest database version. Please upgrade your database to latest database version.', 'ErrMandatoryFieldRequired': 'The field \'{0}\' is mandatory. You must enter data in this field before saving the form.', 'errNoFreeLocation': 'There is no free destination location', 'ErrOldPassword': 'Old (current) password incorrect for user. The password was not changed.', 'Error': 'Error', 'ErrPasswordExpired': 'Your password is expired. Please change your password.', 'ErrPasswordPolicy': 'Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirement.', 'ErrPost': 'Error during saving data in database.', 'errSampleInTransfer': 'Sample "{0}" is already included in transfer "{1}"', 'errSQLLoginError': 'Cannot connect to SQL server. Check the correctness of SQL connection parameters in the SQL Server tab or SQL server accessibility.', 'ErrSqlQuery': 'Error during executing sql query.', 'errSqlServerDoesntExist': 'Can\'t connect to the SQLServer. Please check that network connection is established, SQL Server is not shut down and try to open this form again.', 'errSqlServerNotFound': 'Cannot connect to SQL server \'{0}\'. Check the correctness of SQL server name or SQL server accessibility.', 'ErrStoredProcedure': 'Error during executing database stored procedure.', 'ErrUndefinedStdError': 'Some error occurs in the application. Please send information about this error to software development team.', 'errUnknownError': 'Some error occured in application', 'ErrUnprocessedError': 'Some error occurs in the application. Please send information about this error to software development team.', 'ErrUserNotFound': 'Combination of user/password you entered is not correct.', 'ErrWebTemporarilyUnavailableFunction': 'ErrWebTemporarilyUnavailableFunction', 'Message': 'Message', 'msgCancel': 'All entered data will be lost. Continue?', 'msgCantDeleteRecord': 'The record can not be deleted.', 'msgClearControl': 'Press Ctrl-Del to clear value.', 'msgConfimation': 'Confirmation', 'msgConfirmClearFlexForm': 'Clear the panel content?', 'msgConfirmClearLookup': 'Clear the content?', 'msgDeletePrompt': 'The object will be deleted. Delete object?', 'msgDeleteRecordPrompt': 'The record(s) will be deleted. Delete?', 'msgCancelPrompt': 'Do you want to cancel all the changes and close the form?', 'msgSavePrompt': 'Do you want to save changes?', 'msgUnsavedRecordsPrompt': 'You have some unsaved records. Do you want to save changes before applying a new search (unsaved changes will be undone)?', 'msgOKPrompt': 'Do you want to save changes and close the form?', 'msgEIDSSCopyright': 'Copyright © 2005-2014 Black && Veatch Special Projects Corp.', 'msgEIDSSRunning': 'You can\'t run multiple EIDSS instances simultaneously. Other instance of EIDSS is running already', 'msgEmptyLogin': 'Login is not defined', 'msgMessage': 'Message', 'msgNoDeletePermission': 'You have no rights to delete this object', 'msgNoFreeSpace': 'No free space on location.', 'msgNoInsertPermission': 'You have no rights to create this object', 'msgNoRecordsFound': 'No records is found for current search criteria.', 'msgNoSelectPermission': 'You have no rights to view this form', 'msgParameterAlreadyExists': 'Field Already Exists', 'msgPasswordChanged': 'Your password has been successfully changed', 'msgPasswordNotTheSame': 'New and Confirmed passwords must match', 'msgReasonEmpty': 'Input reason for change', 'msgReplicationPrompt': 'Start the replication to transfer data on other sites?', 'msgREplicationPromptCaption': 'Confirm Replication', 'msgWaitFormCaption': 'Please wait', 'msgFormLoading': 'The form is loading', 'msgWrongDiagnosis': 'The changed diagnosis ({0}) should differ from the initial diagnosis ({1}).', 'Save data?': 'Save data?', 'Warning': 'Warning message', 'SecurityLog_EIDSS_finished_successfully': 'EIDSS finished successfully', 'SecurityLog_EIDSS_started_abnormaly': 'EIDSS started abnormaly', 'SecurityLog_EIDSS_started_successfully': 'EIDSS started successfully', 'strCancel_Id': 'Cancel', 'strChangeDiagnosisReason_msgId': 'Reason is required.', 'strDelete_Id': 'Delete', 'strOK_Id': 'OK', 'tooltipCancel_Id': 'Cancel', 'tooltipClose_Id': 'Close', 'tooltipDelete_Id': 'Delete', 'tooltipOK_Id': 'OK', 'titleAccessionDetails': 'Accession Details', 'titleAntibiotic': 'Antibiotic', 'titleContactInformation': 'Person Details and Contact Information', 'titleDiagnosisChange': 'Diagnosis Change', 'titleDuplicates': 'Duplicates', 'titleEmployeeDetails': 'Employee Details', 'titleEmployeeList': 'Employees List', 'titleGeoLocation': 'Geographic Location', 'titleHumanCaseList': 'Human Cases List', 'titleOrganizationList': 'Organizations List', 'titleOutbreakList': 'Outbreaks List', 'titlePersonsList': 'Persons List', 'titleFarmList': 'titleFarmList', 'titleTestResultChange': 'Amend Test Result', 'titleAccessionInComment': 'Accession In Comment', 'titleSampleDetails': 'Sample Details', 'titleSummaryInfo': 'Summary Info', 'titleOutbreakNote': 'Note', 'errLoginMandatoryFields': 'All fields are mandatory.', 'msgAddToPreferencesPrompt': 'Selected records will be added to preferences.', 'msgRemoveFromPreferencesPrompt': 'Selected records will be removed from preferences.', 'strAdd_Id': 'Add', 'strRemove_Id': 'Remove', 'titleResultSummary': 'Results Summary and Interpretation', 'titleVeterinaryCaseList': 'Veterinary Cases List', 'titleVsSessionList': 'Vector Surveillance Sessions List', 'titlePensideTest': 'Penside Test', 'titleVetCaseLog': 'Action Required', 'titleASSessionList': 'Active Surveillance Sessions List', 'titleTestResultDetails': 'Test Result Details', 'ErrObjectCantBeDeleted': 'Object can\'t be deleted.', 'titleVaccination': 'Vaccination', 'msgAsSessionNoCaseCreated': 'There are no positive samples.', 'strYes_Id': 'Yes', 'strNo_Id': 'No', 'titleClinicalSigns': 'Clinical Signs', 'LastName': 'Last', 'FirstName': 'First', 'MiddleName': 'Middle', 'AsCampaign_GetSessionRemovalConfirmation': 'Do you really want to remove the link to the selected Session?', 'titleSelectFarm': 'Farms List', 'strInfo': 'Info', 'strSearchPanelMandatoryFields_msgId': 'Please fill all mandatory fields of Search Panel', 'menuCreateAliquot': 'Create Aliquot', 'menuCreateDerivative': 'Create Derivative', 'titleCreateAliquot': 'Create Aliquots', 'titleCreateDerivative': 'Create Derivatives', 'menuTransferOutSample': 'Transfer Out', 'titleTransferOutSample': 'Transfer Out', 'menuAccessionInPoorCondition': 'Accepted in poor condition', 'menuAccessionInRejected': 'Rejected', 'menuAmendTestResult': 'Amend Test Result', 'menuAssignTest': 'Assign Test', 'titleAnimals': 'Animals', 'titleCreateSample': 'Register a new sample', 'titleGroupAccessionIn': 'Group Accession In', 'tabTitleSampleTest': 'Sample/Test Details', 'noEmployeeSelectedErrorMessage': 'Please select an employee', 'Species': 'Species', 'titleClinicalInvestigation': 'Species Epidemiological and Clinical Investigation', 'titleAddDisease': 'Disease and Species', 'titleListDetectedDiseases': 'List of Detected Diseases', 'titleDetectedDisease': 'titleDetectedDisease', 'Active Surveillance Session': 'Active Surveillance Session', 'titleAction': 'Action', 'titleHumanAggregateCasesList': 'Human Aggregate Cases List', 'titleVetAggregateCasesList': 'Veterinary Aggregate Cases List', 'titleVetAggregateActionsList': 'Veterinary Aggregate Actions List', 'titleCopyVector': 'Copy Vector', 'titleAddParameter': 'Add Parameter', 'msgTooBigRecordsCount': 'Number of returned records is too big. Not all records are shown on the form. Please change search criteria and try again', 'titleCopySample': 'Copy', 'titleAnimalSampleInfo': 'Animal/Sample Info', 'titleAnimalsSamplesInfo': 'Animals/Samples Info', 'titleDiagnosisHistory': 'Diagnosis History', 'strMap': 'Map', 'ErrAllMandatoryFieldsRequired': 'You must enter data in all mandatory fields.', 'msgTooManyDiagnosis': 'You have selected too many diagnoses. Only first 0 will be displayed in the report.' } }
EIDSS/EIDSS-Legacy
EIDSS v6/eidss.webclient/Scripts/Messages/EIDSS.BvMessages.en-US.js
JavaScript
bsd-2-clause
10,573
# VStripe Ever heard of synchroballistic photography? VStripe renders pictures from videos that look very much like their analog counterparts of the 1980s. For details see [issue 16/11 of the German computer magazine c't](http://heise.de/-1281476).
ola-ct/vstripe
README.md
Markdown
bsd-2-clause
250
package com.agiledropzone.batchtester; import java.io.IOException; import com.agiledropzone.batchtester.tools.ScenarioSyntaxException; /** * Classe de lancement de BatchTester. <br> * */ public class BatchTester { private static String syntaxe = "Syntaxe d'appel :\njava -jar batchtester.jar <NomFichierScenario>"; /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { if (args.length == 0) { System.err.println(syntaxe); System.exit(1); } Thread.currentThread().setName("MAIN"); // On récupère le scenario de test à travers un fichier spécifique ScenarioPlayer sReader; int exitStatus = -1; try { sReader = new ScenarioPlayer(args[0]); exitStatus = sReader.run(); if (exitStatus == 0) System.out.println("Scénario OK"); } catch (ScenarioSyntaxException e) { System.err.println(e.getMessage()); } System.exit(exitStatus); } }
AgileDropZone/batchtester
src/com/agiledropzone/batchtester/BatchTester.java
Java
bsd-2-clause
1,134
// Copyright (c) Zhirnov Andrey. For more information see 'LICENSE.txt' #pragma once #if 0 #include "Core/STL/Files/SubFile.h" #include "Core/STL/Containers/StaticArray.h" namespace GX_STL { namespace GXFile { // // Simple File Crypt Algorithm // template <uint Size> struct SimpleFileCryptAlgorithm { // types public: typedef StaticArray< ubyte, Size > password_t; typedef SimpleFileCryptAlgorithm< Size > Self; // variables private: password_t _password; // methods public: SimpleFileCryptAlgorithm (StringCRef password) : _password(0) { for (usize i = 0; i < password.Length() and i < _password.Count(); ++i) { _password[i] = password[i]; } } SimpleFileCryptAlgorithm (BinArrayCRef password) : _password(0) { for (usize i = 0; i < password.Count() and i < _password.Count(); ++i) { _password[i] = password[i]; } } void Encrypt (BytesU pos, INOUT ubyte &c) const { FOR( i, _password ) { c ^= _password[i] + (pos * i); } } void Decrypt (BytesU pos, INOUT ubyte &c) const { Encrypt( pos, c ); } }; // // Read only Crypted Sub File // template <typename A> class RCryptFile : public SubRFile { // types public: typedef A CryptAlgorithm; typedef RCryptFile<A> Self; typedef SharedPointerType<Self> RCryptFilePtr; // variables private: CryptAlgorithm _crypt; // methods public: RCryptFile (const RFilePtr &file, const CryptAlgorithm &alg) : SubRFile( file, file->Pos(), file->RemainingSize() ), _crypt(alg) {} RCryptFile (const RFilePtr &file, BytesU offset, BytesU size, const CryptAlgorithm &alg) : SubRFile( file, offset, size ), _crypt(alg) {} ND_ static RCryptFilePtr New (const RFilePtr &file, const CryptAlgorithm &alg) { return new Self( file, alg ); } ND_ static RCryptFilePtr New (const RFilePtr &file, BytesU offset, BytesU size, const CryptAlgorithm &alg) { return new Self( file, offset, size, alg ); } // RFile // virtual BytesU ReadBuf (void * buf, BytesU size) noexcept override { ubyte * data = Cast<ubyte *>(buf); BytesU pos = Pos(); BytesU r = SubRFile::ReadBuf( buf, size ); if ( r > 0 ) { for (usize i = 0; i < usize(r); ++i) { _crypt.Decrypt( pos + i, data[i] ); } } return r; } // BaseFile // virtual EFile::type GetType () const override { return EFile::Crypted; } private: static SubRFilePtr New (const RFilePtr &file, BytesU offset, BytesU size) = delete; }; // // Write only Crypted Sub File // template <typename A> class WCryptFile : public SubWFile { // types public: typedef A CryptAlgorithm; typedef WCryptFile<A> Self; typedef SharedPointerType<Self> WCryptFilePtr; // variables private: CryptAlgorithm _crypt; bool _restoreData; // methods public: WCryptFile (const WFilePtr &file, const CryptAlgorithm &alg, bool restoreData = true) : SubWFile( file, file->Pos(), file->RemainingSize() ), _crypt(alg), _restoreData(restoreData) {} WCryptFile (const WFilePtr &file, BytesU offset, BytesU size, const CryptAlgorithm &alg, bool restoreData = true) : SubWFile( file, offset, size ), _crypt(alg), _restoreData(restoreData) {} ND_ static WCryptFilePtr New (const WFilePtr &file, const CryptAlgorithm &alg, bool restoreData = true) { return new Self( file, alg, restoreData ); } ND_ static WCryptFilePtr New (const WFilePtr &file, BytesU offset, BytesU size, const CryptAlgorithm &alg, bool restoreData = true) { return new Self( file, offset, size, alg, restoreData ); } // WFile // virtual BytesU WriteBuf (const void * buf, BytesU size) noexcept override { ubyte * data = Cast<ubyte *>(buf); BytesU pos = Pos(); for (usize i = 0; i < size; ++i) { _crypt.Encrypt( pos + i, data[i] ); } BytesU w = SubWFile::WriteBuf( buf, size ); if ( _restoreData ) { for (usize i = 0; i < size; ++i) { _crypt.Decrypt( pos + i, data[i] ); } } return w; } // BaseFile // virtual EFile::type GetType () const override { return EFile::Crypted; } private: static SubWFilePtr New (const WFilePtr &file, BytesU offset, BytesU size) = delete; }; } // GXFile } // GX_STL #endif
azhirnov/GraphicsGenFramework-modular
Core/STL/Files/CryptFile.h
C
bsd-2-clause
4,286
#!/bin/bash MODULE_NAME="vdphci" DEVICE_NAME="vdphcidev" DEVICE_LOWER=0 DEVICE_UPPER=10 sudo insmod ./$MODULE_NAME.ko $* || exit 1 # Retrieve major number DEVICE_MAJOR=`awk "\\$2==\"$MODULE_NAME\" {print \\$1}" /proc/devices` sudo rm -f /dev/${DEVICE_NAME}* for (( I=$DEVICE_LOWER; I<=$DEVICE_UPPER; I++ )) do sudo mknod /dev/${DEVICE_NAME}${I} c $DEVICE_MAJOR $I sudo chmod 0666 /dev/${DEVICE_NAME}${I} done
Sheph/vdp
modules/vdphci/vdphci-load.sh
Shell
bsd-2-clause
421
<?php class Kwc_Root_TrlRoot_Slave_Component extends Kwc_Root_TrlRoot_Chained_Component { public static function getSettings($masterComponentClass = null) { $ret = parent::getSettings($masterComponentClass); $ret['generators']['page']['class'] = 'Kwc_Root_Category_Trl_Generator'; $ret['generators']['page']['model'] = 'Kwc_Root_TrlRoot_Slave_Model'; return $ret; } }
koala-framework/koala-framework
tests/Kwc/Root/TrlRoot/Slave/Component.php
PHP
bsd-2-clause
412
cask "pdfsam-basic" do version "4.2.3" sha256 "7018ddb963c6a7e7782ddba77776de488bdfdacfdb3212702afda0c4f5cb2475" url "https://github.com/torakiki/pdfsam/releases/download/v#{version}/PDFsam-#{version}.dmg", verified: "github.com/torakiki/pdfsam/" name "PDFsam Basic" desc "Extractas pages, splits, merges, mixes and rotates PDF files" homepage "https://pdfsam.org/" app "PDFsam Basic.app" zap trash: [ "~/Library/Preferences/org.pdfsam.modules.plist", "~/Library/Preferences/org.pdfsam.stage.plist", "~/Library/Preferences/org.pdfsam.user.plist", "~/Library/Saved Application State/org.pdfsam.basic.savedState", ] end
renaudguerin/homebrew-cask
Casks/pdfsam-basic.rb
Ruby
bsd-2-clause
661
/** @file Copyright (c) 2015, Linaro Limited. All rights reserved. Copyright (c) 2015, Hisilicon Limited. All rights reserved. Copyright (c) 2017, Jeremy Linton. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include <IndustryStandard/Usb.h> #include <Library/TimerLib.h> #include <Library/DebugLib.h> #include <Library/UefiBootServicesTableLib.h> #include <Library/UefiDriverEntryPoint.h> #include <Library/UefiLib.h> #include <Library/UefiRuntimeServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h> #include <Library/IoLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/UncachedMemoryAllocationLib.h> #include <Library/CacheMaintenanceLib.h> #include <Library/BaseMemoryLib.h> #include <Library/BaseLib.h> #include <Protocol/UsbDevice.h> #include <Protocol/UsbHostController.h> #include <Protocol/Usb2HostController.h> #include <Protocol/PciIo.h> #include <IndustryStandard/Pci.h> #include "DwUsbDxe.h" #include "Hi6220.h" // Blah, the existing hikey driver only works in OTG mode (aka its an endpoint device for fastboot) // out of the box this driver configures a made up protocol which // setups the port to act as a fastboot programming taget. This sucks! #ifdef NOTACTIVE STATIC dwc_otg_dev_dma_desc_t *g_dma_desc,*g_dma_desc_ep0,*g_dma_desc_in; STATIC USB_DEVICE_REQUEST *p_ctrlreq; STATIC VOID *rx_buf; STATIC UINT32 rx_desc_bytes = 0; STATIC UINTN mNumDataBytes; #define USB_BLOCK_HIGH_SPEED_SIZE 512 #define DATA_SIZE 32768 #define CMD_SIZE 512 #define MATCH_CMD_LITERAL(Cmd, Buf) !AsciiStrnCmp (Cmd, Buf, sizeof (Cmd) - 1) STATIC USB_DEVICE_DESCRIPTOR *mDeviceDescriptor; // The config descriptor, interface descriptor, and endpoint descriptors in a // buffer (in that order) STATIC VOID *mDescriptors; // Convenience pointers to those descriptors inside the buffer: STATIC USB_INTERFACE_DESCRIPTOR *mInterfaceDescriptor; STATIC USB_CONFIG_DESCRIPTOR *mConfigDescriptor; STATIC USB_ENDPOINT_DESCRIPTOR *mEndpointDescriptors; STATIC USB_DEVICE_RX_CALLBACK mDataReceivedCallback; STATIC USB_DEVICE_TX_CALLBACK mDataSentCallback; STATIC EFI_USB_STRING_DESCRIPTOR mLangStringDescriptor = { 4, USB_DESC_TYPE_STRING, {0x409} }; // The time between interrupt polls, in units of 100 nanoseconds // 10 Microseconds #define DW_INTERRUPT_POLL_PERIOD 10000 STATIC int usb_drv_port_speed(void) /*To detect which mode was run, high speed or full speed*/ { /* * 2'b00: High speed (PHY clock is running at 30 or 60 MHz) */ UINT32 val = READ_REG32(DSTS) & 2; return (!val); } STATIC VOID reset_endpoints(void) { /* EP0 IN ACTIVE NEXT=1 */ WRITE_REG32(DIEPCTL0, 0x8800); /* EP0 OUT ACTIVE */ WRITE_REG32(DOEPCTL0, 0x8000); /* Clear any pending OTG Interrupts */ WRITE_REG32(GOTGINT, 0xFFFFFFFF); /* Clear any pending interrupts */ WRITE_REG32(GINTSTS, 0xFFFFFFFF); WRITE_REG32(DIEPINT0, 0xFFFFFFFF); WRITE_REG32(DOEPINT0, 0xFFFFFFFF); WRITE_REG32(DIEPINT1, 0xFFFFFFFF); WRITE_REG32(DOEPINT1, 0xFFFFFFFF); /* IN EP interrupt mask */ WRITE_REG32(DIEPMSK, 0x0D); /* OUT EP interrupt mask */ WRITE_REG32(DOEPMSK, 0x0D); /* Enable interrupts on Ep0 */ WRITE_REG32(DAINTMSK, 0x00010001); /* EP0 OUT Transfer Size:64 Bytes, 1 Packet, 3 Setup Packet, Read to receive setup packet*/ WRITE_REG32(DOEPTSIZ0, 0x60080040); //notes that:the compulsive conversion is expectable. g_dma_desc_ep0->status.b.bs = 0x3; g_dma_desc_ep0->status.b.mtrf = 0; g_dma_desc_ep0->status.b.sr = 0; g_dma_desc_ep0->status.b.l = 1; g_dma_desc_ep0->status.b.ioc = 1; g_dma_desc_ep0->status.b.sp = 0; g_dma_desc_ep0->status.b.bytes = 64; g_dma_desc_ep0->buf = (UINT32)(UINTN)(p_ctrlreq); g_dma_desc_ep0->status.b.sts = 0; g_dma_desc_ep0->status.b.bs = 0x0; WRITE_REG32(DOEPDMA0, (unsigned long)(g_dma_desc_ep0)); /* EP0 OUT ENABLE CLEARNAK */ WRITE_REG32(DOEPCTL0, (READ_REG32(DOEPCTL0) | 0x84000000)); } STATIC VOID ep_tx(IN UINT8 ep, CONST VOID *ptr, UINT32 len) { UINT32 blocksize; UINT32 packets; /* EPx OUT ACTIVE */ WRITE_REG32(DIEPCTL(ep), (READ_REG32(DIEPCTL(ep))) | 0x8000); if(!ep) { blocksize = 64; } else { blocksize = usb_drv_port_speed() ? USB_BLOCK_HIGH_SPEED_SIZE : 64; } packets = (len + blocksize - 1) / blocksize; if (!len) { //send a null packet /* one empty packet */ g_dma_desc_in->status.b.bs = 0x3; g_dma_desc_in->status.b.l = 1; g_dma_desc_in->status.b.ioc = 1; g_dma_desc_in->status.b.sp = 1; g_dma_desc_in->status.b.bytes = 0; g_dma_desc_in->buf = 0; g_dma_desc_in->status.b.sts = 0; g_dma_desc_in->status.b.bs = 0x0; WRITE_REG32(DIEPDMA(ep), (unsigned long)(g_dma_desc_in)); // DMA Address (DMAAddr) is zero } else { //prepare to send a packet /*WRITE_REG32((len | (packets << 19)), DIEPTSIZ(ep));*/ // packets+transfer size WRITE_REG32(DIEPTSIZ(ep), len | (packets << 19)); //flush cache WriteBackDataCacheRange ((void*)ptr, len); g_dma_desc_in->status.b.bs = 0x3; g_dma_desc_in->status.b.l = 1; g_dma_desc_in->status.b.ioc = 1; g_dma_desc_in->status.b.sp = 1; g_dma_desc_in->status.b.bytes = len; g_dma_desc_in->buf = (UINT32)((UINTN)ptr); g_dma_desc_in->status.b.sts = 0; g_dma_desc_in->status.b.bs = 0x0; WRITE_REG32(DIEPDMA(ep), (unsigned long)(g_dma_desc_in)); // ptr is DMA address } asm("dsb sy"); asm("isb sy"); /* epena & cnak*/ WRITE_REG32(DIEPCTL(ep), READ_REG32(DIEPCTL(ep)) | 0x84000800); return; } STATIC VOID ep_rx(unsigned ep, UINT32 len) { /* EPx UNSTALL */ WRITE_REG32(DOEPCTL(ep), ((READ_REG32(DOEPCTL(ep))) & (~0x00200000))); /* EPx OUT ACTIVE */ WRITE_REG32(DOEPCTL(ep), (READ_REG32(DOEPCTL(ep)) | 0x8000)); if (len >= DATA_SIZE) rx_desc_bytes = DATA_SIZE; else rx_desc_bytes = len; rx_buf = AllocatePool (DATA_SIZE); ASSERT (rx_buf != NULL); InvalidateDataCacheRange (rx_buf, len); g_dma_desc->status.b.bs = 0x3; g_dma_desc->status.b.mtrf = 0; g_dma_desc->status.b.sr = 0; g_dma_desc->status.b.l = 1; g_dma_desc->status.b.ioc = 1; g_dma_desc->status.b.sp = 0; g_dma_desc->status.b.bytes = rx_desc_bytes; g_dma_desc->buf = (UINT32)((UINTN)rx_buf); g_dma_desc->status.b.sts = 0; g_dma_desc->status.b.bs = 0x0; asm("dsb sy"); asm("isb sy"); WRITE_REG32(DOEPDMA(ep), (UINT32)((UINTN)g_dma_desc)); /* EPx OUT ENABLE CLEARNAK */ WRITE_REG32(DOEPCTL(ep), (READ_REG32(DOEPCTL(ep)) | 0x84000000)); } STATIC EFI_STATUS HandleGetDescriptor ( IN USB_DEVICE_REQUEST *Request ) { UINT8 DescriptorType; UINTN ResponseSize; VOID *ResponseData; // CHAR16 SerialNo[16]; // UINTN SerialNoLen; // EFI_STATUS Status; ResponseSize = 0; ResponseData = NULL; // Pretty confused if bmRequestType is anything but this: ASSERT (Request->RequestType == USB_DEV_GET_DESCRIPTOR_REQ_TYPE); // Choose the response DescriptorType = Request->Value >> 8; switch (DescriptorType) { case USB_DESC_TYPE_DEVICE: DEBUG ((EFI_D_ERROR, "USB: Got a request for device descriptor\n")); ResponseSize = sizeof (USB_DEVICE_DESCRIPTOR); ResponseData = mDeviceDescriptor; break; case USB_DESC_TYPE_CONFIG: DEBUG ((EFI_D_ERROR, "USB: Got a request for config descriptor\n")); ResponseSize = mConfigDescriptor->TotalLength; ResponseData = mDescriptors; break; case USB_DESC_TYPE_STRING: DEBUG ((EFI_D_ERROR, "USB: Got a request for String descriptor %d\n", Request->Value & 0xFF)); switch (Request->Value & 0xff) { case 0: ResponseSize = mLangStringDescriptor.Length; ResponseData = &mLangStringDescriptor; break; case 1: ResponseSize = mManufacturerStringDescriptor.Hdr.Length; ResponseData = &mManufacturerStringDescriptor; break; case 2: ResponseSize = mProductStringDescriptor.Hdr.Length; ResponseData = &mProductStringDescriptor; break; case 3: /* Status = gRT->GetVariable ( (CHAR16*)L"SerialNo", &gArmGlobalVariableGuid, NULL, &SerialNoLen, SerialNo ); if (EFI_ERROR (Status) == 0) { CopyMem (mSerialStringDescriptor.String, SerialNo, SerialNoLen); } ResponseSize = mSerialStringDescriptor.Length; ResponseData = &mSerialStringDescriptor;*/ CopyMem (mSerialStringDescriptor.Hdr.String, "12345", 6); ResponseSize = 6; ResponseData = &mSerialStringDescriptor; break; } break; default: DEBUG ((EFI_D_ERROR, "USB: Didn't understand request for descriptor 0x%04x\n", Request->Value)); break; } // Send the response if (ResponseData) { ASSERT (ResponseSize != 0); if (Request->Length < ResponseSize) { // Truncate response ResponseSize = Request->Length; } else if (Request->Length > ResponseSize) { DEBUG ((EFI_D_ERROR, "USB: Info: ResponseSize < wLength\n")); } ep_tx(0, ResponseData, ResponseSize); } return EFI_SUCCESS; } STATIC EFI_STATUS HandleSetAddress ( IN USB_DEVICE_REQUEST *Request ) { // Pretty confused if bmRequestType is anything but this: ASSERT (Request->RequestType == USB_DEV_SET_ADDRESS_REQ_TYPE); DEBUG ((EFI_D_ERROR, "USB: Setting address to %d\n", Request->Value)); reset_endpoints(); WRITE_REG32(DCFG, (READ_REG32(DCFG) & ~0x7F0) | (Request->Value << 4)); ep_tx(0, 0, 0); return EFI_SUCCESS; } int usb_drv_request_endpoint(unsigned int type, int dir) { unsigned int ep = 1; /*FIXME*/ int ret; unsigned long newbits; ret = (int)ep | dir; newbits = (type << 18) | 0x10000000; /* * (type << 18):Endpoint Type (EPType) * 0x10000000:Endpoint Enable (EPEna) * 0x000C000:Endpoint Type (EPType);Hardcoded to 00 for control. * (ep<<22):TxFIFO Number (TxFNum) * 0x20000:NAK Status (NAKSts);The core is transmitting NAK handshakes on this endpoint. */ if (dir) { // IN: to host WRITE_REG32(DIEPCTL(ep), ((READ_REG32(DIEPCTL(ep)))& ~0x000C0000) | newbits | (ep<<22)|0x20000); } else { // OUT: to device WRITE_REG32(DOEPCTL(ep), ((READ_REG32(DOEPCTL(ep))) & ~0x000C0000) | newbits); } return ret; } STATIC EFI_STATUS HandleSetConfiguration ( IN USB_DEVICE_REQUEST *Request ) { ASSERT (Request->RequestType == USB_DEV_SET_CONFIGURATION_REQ_TYPE); // Cancel all transfers reset_endpoints(); usb_drv_request_endpoint(2, 0); usb_drv_request_endpoint(2, 0x80); WRITE_REG32(DIEPCTL1, (READ_REG32(DIEPCTL1)) | 0x10088800); /* Enable interrupts on all endpoints */ WRITE_REG32(DAINTMSK, 0xFFFFFFFF); ep_rx(1, CMD_SIZE); ep_tx(0, 0, 0); return EFI_SUCCESS; } STATIC EFI_STATUS HandleDeviceRequest ( IN USB_DEVICE_REQUEST *Request ) { EFI_STATUS Status; switch (Request->Request) { case USB_DEV_GET_DESCRIPTOR: Status = HandleGetDescriptor (Request); break; case USB_DEV_SET_ADDRESS: Status = HandleSetAddress (Request); break; case USB_DEV_SET_CONFIGURATION: Status = HandleSetConfiguration (Request); break; default: DEBUG ((EFI_D_ERROR, "Didn't understand RequestType 0x%x Request 0x%x\n", Request->RequestType, Request->Request)); Status = EFI_INVALID_PARAMETER; break; } return Status; } // Instead of actually registering interrupt handlers, we poll the controller's // interrupt source register in this function. STATIC VOID CheckInterrupts ( IN EFI_EVENT Event, IN VOID *Context ) { UINT32 ints = READ_REG32(GINTSTS); // interrupt register UINT32 epints; /* * bus reset * The core sets this bit to indicate that a reset is detected on the USB. */ if (ints & 0x1000) { WRITE_REG32(DCFG, 0x800004); reset_endpoints(); } /* * enumeration done, we now know the speed * The core sets this bit to indicate that speed enumeration is complete. The * application must read the Device Status (DSTS) register to obtain the * enumerated speed. */ if (ints & 0x2000) { /* Set up the maximum packet sizes accordingly */ unsigned long maxpacket = usb_drv_port_speed() ? USB_BLOCK_HIGH_SPEED_SIZE : 64; //Set Maximum In Packet Size (MPS) WRITE_REG32(DIEPCTL1, ((READ_REG32(DIEPCTL1)) & ~0x000003FF) | maxpacket); //Set Maximum Out Packet Size (MPS) WRITE_REG32(DOEPCTL1, ((READ_REG32(DOEPCTL1)) & ~0x000003FF) | maxpacket); } /* * IN EP event * The core sets this bit to indicate that an interrupt is pending on one of the IN * endpoints of the core (in Device mode). The application must read the * Device All Endpoints Interrupt (DAINT) register to determine the exact * number of the IN endpoint on which the interrupt occurred, and then read * the corresponding Device IN Endpoint-n Interrupt (DIEPINTn) register to * determine the exact cause of the interrupt. The application must clear the * appropriate status bit in the corresponding DIEPINTn register to clear this bit. */ if (ints & 0x40000) { epints = READ_REG32(DIEPINT0); WRITE_REG32(DIEPINT0, epints); if (epints & 0x1) /* Transfer Completed Interrupt (XferCompl) */ DEBUG ((EFI_D_ERROR, "INT: IN TX completed.DIEPTSIZ(0) = 0x%x.\n", READ_REG32(DIEPTSIZ0))); epints = READ_REG32(DIEPINT1); WRITE_REG32(DIEPINT1, epints); if (epints & 0x1) DEBUG ((EFI_D_ERROR, "ep1: IN TX completed\n")); } /* * OUT EP event * The core sets this bit to indicate that an interrupt is pending on one of the * OUT endpoints of the core (in Device mode). The application must read the * Device All Endpoints Interrupt (DAINT) register to determine the exact * number of the OUT endpoint on which the interrupt occurred, and then read * the corresponding Device OUT Endpoint-n Interrupt (DOEPINTn) register * to determine the exact cause of the interrupt. The application must clear the * appropriate status bit in the corresponding DOEPINTn register to clear this bit. */ if (ints & 0x80000) { /* indicates the status of an endpoint * with respect to USB- and AHB-related events. */ epints = READ_REG32(DOEPINT0); if(epints) { WRITE_REG32(DOEPINT0, epints); if (epints & 0x1) DEBUG ((EFI_D_ERROR,"INT: EP0 RX completed. DOEPTSIZ(0) = 0x%x.\n", READ_REG32(DOEPTSIZ0))); /* * IN Token Received When TxFIFO is Empty (INTknTXFEmp) * Indicates that an IN token was received when the associated TxFIFO (periodic/nonperiodic) * was empty. This interrupt is asserted on the endpoint for which the IN token * was received. */ if (epints & 0x8) { /* SETUP phase done */ // PRINT_DEBUG("Setup phase \n"); WRITE_REG32(DIEPCTL0, READ_REG32(DIEPCTL0) | 0x08000000); WRITE_REG32(DOEPCTL0, READ_REG32(DOEPCTL0) | 0x08000000); /*clear IN EP intr*/ WRITE_REG32(DIEPINT0, 0xffffffff); HandleDeviceRequest((USB_DEVICE_REQUEST *)p_ctrlreq); } /* Make sure EP0 OUT is set up to accept the next request */ /* memset(p_ctrlreq, 0, NUM_ENDPOINTS*8); */ WRITE_REG32(DOEPTSIZ0, 0x60080040); /* * IN Token Received When TxFIFO is Empty (INTknTXFEmp) * Indicates that an IN token was received when the associated TxFIFO (periodic/nonperiodic) * was empty. This interrupt is asserted on the endpoint for which the IN token * was received. */ g_dma_desc_ep0->status.b.bs = 0x3; g_dma_desc_ep0->status.b.mtrf = 0; g_dma_desc_ep0->status.b.sr = 0; g_dma_desc_ep0->status.b.l = 1; g_dma_desc_ep0->status.b.ioc = 1; g_dma_desc_ep0->status.b.sp = 0; g_dma_desc_ep0->status.b.bytes = 64; g_dma_desc_ep0->buf = (UINT32)(UINTN)(p_ctrlreq); g_dma_desc_ep0->status.b.sts = 0; g_dma_desc_ep0->status.b.bs = 0x0; WRITE_REG32(DOEPDMA0, (unsigned long)(g_dma_desc_ep0)); // endpoint enable; clear NAK WRITE_REG32(DOEPCTL0, 0x84000000); } epints = (READ_REG32(DOEPINT1)); if(epints) { WRITE_REG32(DOEPINT1, epints); /* Transfer Completed Interrupt (XferCompl);Transfer completed */ if (epints & 0x1) { asm("dsb sy"); asm("isb sy"); UINT32 bytes = rx_desc_bytes - g_dma_desc->status.b.bytes; UINT32 len = 0; if (MATCH_CMD_LITERAL ("download", rx_buf)) { mNumDataBytes = AsciiStrHexToUint64 (rx_buf + sizeof ("download")); } else { if (mNumDataBytes != 0) mNumDataBytes -= bytes; } mDataReceivedCallback (bytes, rx_buf); if (mNumDataBytes == 0) len = CMD_SIZE; else if (mNumDataBytes > DATA_SIZE) len = DATA_SIZE; else len = mNumDataBytes; ep_rx(1, len); } } } //WRITE_REG32 clear ints WRITE_REG32(GINTSTS, ints); } EFI_STATUS DwUsbSend ( IN UINT8 EndpointIndex, IN UINTN Size, IN CONST VOID *Buffer ) { ep_tx(EndpointIndex, Buffer, Size); return 0; } STATIC VOID usb_init() { VOID* buf; buf = UncachedAllocatePages (1); g_dma_desc = buf; g_dma_desc_ep0 = g_dma_desc + sizeof(struct dwc_otg_dev_dma_desc); g_dma_desc_in = g_dma_desc_ep0 + sizeof(struct dwc_otg_dev_dma_desc); p_ctrlreq = (USB_DEVICE_REQUEST *)g_dma_desc_in + sizeof(struct dwc_otg_dev_dma_desc); SetMem(g_dma_desc, sizeof(struct dwc_otg_dev_dma_desc), 0); SetMem(g_dma_desc_ep0, sizeof(struct dwc_otg_dev_dma_desc), 0); SetMem(g_dma_desc_in, sizeof(struct dwc_otg_dev_dma_desc), 0); /*Reset usb controller.*/ /* Wait for AHB master idle */ while (!((READ_REG32(GRSTCTL)) & 0x80000000)); /* OTG: Assert Software Reset */ WRITE_REG32(GRSTCTL, 1); /* Wait for OTG to ack reset */ while ((READ_REG32(GRSTCTL)) & 1); /* Wait for OTG AHB master idle */ while (!((READ_REG32(GRSTCTL)) & 0x80000000)); WRITE_REG32(GDFIFOCFG, DATA_FIFO_CONFIG); WRITE_REG32(GRXFSIZ, RX_SIZE); WRITE_REG32(GNPTXFSIZ, ENDPOINT_TX_SIZE); WRITE_REG32(DIEPTXF1, DATA_IN_ENDPOINT_TX_FIFO1); /* * set Periodic TxFIFO Empty Level, * Non-Periodic TxFIFO Empty Level, * Enable DMA, Unmask Global Intr */ WRITE_REG32(GAHBCFG, 0x1a1); /*select 8bit UTMI+, ULPI Inerface*/ WRITE_REG32(GUSBCFG, 0x2400); /* Detect usb work mode,host or device? */ while ((READ_REG32(GINTSTS)) & 1); MicroSecondDelay(1); /*Init global and device mode csr register.*/ /*set Non-Zero-Length status out handshake */ WRITE_REG32(DCFG, 0x800004); /* Interrupt unmask: IN event, OUT event, bus reset */ WRITE_REG32(GINTMSK, 0xC3C08); while ((READ_REG32(GINTSTS)) & 0x2000); /* Clear any pending OTG Interrupts */ WRITE_REG32(GOTGINT, 0xFFFFFFFF); /* Clear any pending interrupts */ WRITE_REG32(GINTSTS, 0xFFFFFFFF); WRITE_REG32(GINTMSK, 0xFFFFFFFF); WRITE_REG32(GOTGINT, READ_REG32(GOTGINT) & (~0x3000)); /*endpoint settings cfg*/ reset_endpoints(); /*init finish. and ready to transfer data*/ /* Soft Disconnect */ WRITE_REG32(DCTL, 0x802); MicroSecondDelay(1); /* Soft Reconnect */ WRITE_REG32(DCTL, 0x800); } EFI_STATUS EFIAPI DwUsbStart ( IN USB_DEVICE_DESCRIPTOR *DeviceDescriptor, IN VOID **Descriptors, IN USB_DEVICE_RX_CALLBACK RxCallback, IN USB_DEVICE_TX_CALLBACK TxCallback ) { UINT8 *Ptr; EFI_STATUS Status; EFI_EVENT TimerEvent; ASSERT (DeviceDescriptor != NULL); ASSERT (Descriptors[0] != NULL); ASSERT (RxCallback != NULL); ASSERT (TxCallback != NULL); usb_init(); mDeviceDescriptor = DeviceDescriptor; mDescriptors = Descriptors[0]; // Right now we just support one configuration ASSERT (mDeviceDescriptor->NumConfigurations == 1); // ... and one interface mConfigDescriptor = (USB_CONFIG_DESCRIPTOR *)mDescriptors; ASSERT (mConfigDescriptor->NumInterfaces == 1); Ptr = ((UINT8 *) mDescriptors) + sizeof (USB_CONFIG_DESCRIPTOR); mInterfaceDescriptor = (USB_INTERFACE_DESCRIPTOR *) Ptr; Ptr += sizeof (USB_INTERFACE_DESCRIPTOR); mEndpointDescriptors = (USB_ENDPOINT_DESCRIPTOR *) Ptr; mDataReceivedCallback = RxCallback; mDataSentCallback = TxCallback; // Register a timer event so CheckInterupts gets called periodically Status = gBS->CreateEvent ( EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, CheckInterrupts, NULL, &TimerEvent ); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { return Status; } Status = gBS->SetTimer ( TimerEvent, TimerPeriodic, DW_INTERRUPT_POLL_PERIOD ); ASSERT_EFI_ERROR (Status); return Status; } USB_DEVICE_PROTOCOL mUsbDevice = { DwUsbStart, DwUsbSend }; #endif STATIC VOID phy_init(USB_OHCI_HC_DEV *Ehc) { UINT32 val; DEBUG ((EFI_D_ERROR, "phy_init() sequence\n")); // setup direction of hub val = GPIO_READ_REG32(GPIODIR); DEBUG ((EFI_D_ERROR, "GPIO0_3=%X DIR=%X CTL=%X\n", GPIO_READ_REG32(GPIODATA_3),val,GPIO_READ_REG32(GPIOAFSEL))); val |= 0x84; GPIO_WRITE_REG32(GPIODIR,val); asm("dsb sy"); asm("isb sy"); MicroSecondDelay (1000); GPIO_WRITE_REG32(GPIODATA_3,1<<3); GPIO_WRITE_REG32(GPIODATA_7,1<<7); asm("dsb sy"); asm("isb sy"); MicroSecondDelay (1000); DEBUG ((EFI_D_ERROR, "GPIO0_3=%X DIR=%X CTL=%X\n", GPIO_READ_REG32(GPIODATA_3),val,GPIO_READ_REG32(GPIOAFSEL))); DEBUG ((EFI_D_ERROR, "GPIO0=%X\n", GPIO_READ_REG32(0x3FC))); // DEBUG ((EFI_D_ERROR, "GPIO0_7=%X\n", GPIO_READ_REG32(GPIODATA_7))); //turn on Hub port /* +STATIC +VOID +HiKeyDetectUsbModeInit ( + IN VOID + ) +{ + EFI_STATUS Status; + + //set pullup on both GPIO2_5 & GPIO2_6. It's required for inupt. + MmioWrite32 (0xf8001864, 1); + MmioWrite32 (0xf8001868, 1); + + Status = gBS->LocateProtocol (&gEmbeddedGpioProtocolGuid, NULL, (VOID **)&mGpio); + ASSERT_EFI_ERROR (Status); + Status = mGpio->Set (mGpio, USB_SEL_GPIO0_3, GPIO_MODE_OUTPUT_0); + ASSERT_EFI_ERROR (Status); + Status = mGpio->Set (mGpio, USB_5V_HUB_EN, GPIO_MODE_OUTPUT_0); + ASSERT_EFI_ERROR (Status); + MicroSecondDelay (1000); + + Status = mGpio->Set (mGpio, USB_ID_DET_GPIO2_5, GPIO_MODE_INPUT); + ASSERT_EFI_ERROR (Status); + Status = mGpio->Set (mGpio, USB_VBUS_DET_GPIO2_6, GPIO_MODE_INPUT); + ASSERT_EFI_ERROR (Status); +} */ //setup clock val = PHY_READ_REG32(SC_PERIPH_CLKEN0); val |= BIT4; PHY_WRITE_REG32(SC_PERIPH_CLKEN0, val); do { val = PHY_READ_REG32(SC_PERIPH_CLKSTAT0); } while ((val & BIT4) == 0); // setup phy (this is just hi6220_phy_init() minus the "reset enable"? // AKA looks like its just pulling the phy out of reset val = PHY_READ_REG32(SC_PERIPH_RSTDIS0); val |= RST0_USBOTG_BUS | RST0_POR_PICOPHY | RST0_USBOTG | RST0_USBOTG_32K; PHY_WRITE_REG32(SC_PERIPH_RSTDIS0, val); // this is the "on" mode from linux hi6220_phy_setup() val = PHY_READ_REG32(SC_PERIPH_CTRL5); val &= ~CTRL5_PICOPHY_BC_MODE; val |= CTRL5_USBOTG_RES_SEL | CTRL5_PICOPHY_ACAENB; //newer HIsi edk has this | CTRL5_PICOPHY_VDATDETENB | CTRL5_PICOPHY_DCDENB; ; PHY_WRITE_REG32(SC_PERIPH_CTRL5, val); val = PHY_READ_REG32(SC_PERIPH_CTRL4); val &= ~(CTRL4_PICO_SIDDQ | CTRL4_PICO_OGDISABLE); val |= CTRL4_PICO_VBUSVLDEXT | CTRL4_PICO_VBUSVLDEXTSEL | CTRL4_OTG_PHY_SEL; PHY_WRITE_REG32(SC_PERIPH_CTRL4, val); PHY_WRITE_REG32(SC_PERIPH_CTRL8, EYE_PATTERN_PARA); } // Try to get the controller inited, the appropriate linux function // is probably dwc2_core_host_init() STATIC VOID DwHostInit(USB_OHCI_HC_DEV *Ehc) { UINT32 reg; // rpi needs the USB controller powered? // do we? // play with PCGCCTL /* status = dwc_power_on(); if (status != USB_STATUS_SUCCESS) { return status; }*/ DEBUG ((EFI_D_ERROR, "DwHostInit reset\n")); /*Reset usb controller.*/ /* Wait for AHB master idle */ while (!((READ_REG32(GRSTCTL)) & GRSTCTL_AHBIDLE)); /* Assert Software Reset */ WRITE_REG32(GRSTCTL, GRSTCTL_CSFTRST); /* Wait for ack reset */ while ((READ_REG32(GRSTCTL)) & GRSTCTL_CSFTRST); /* Wait for AHB master idle */ while (!((READ_REG32(GRSTCTL)) & GRSTCTL_AHBIDLE)); // version reg=READ_REG32(GSNPSID); //global rx fifo size DEBUG ((EFI_D_ERROR, "DwHostInit version %X\n",reg)); DEBUG ((EFI_D_ERROR, "DwHostInit setup dma\n")); reg=READ_REG32(GRXFSIZ); //global rx fifo size DEBUG ((EFI_D_ERROR, "DwHostInit global rx fifo size 0x%X\n",reg)); reg=READ_REG32(GNPTXFSIZ); //global np tx fifo size DEBUG ((EFI_D_ERROR, "DwHostInit global np tx fifo size 0x%X\n",reg)); reg=READ_REG32(HPTXFSIZ); //global tx fifo size DEBUG ((EFI_D_ERROR, "DwHostInit global tx fifo size 0x%X\n",reg)); reg=READ_REG32(GNPTXSTS); //global np tx fifo status DEBUG ((EFI_D_ERROR, "DwHostInit global np tx fifo status 0x%X\n",reg)); reg=READ_REG32(GAHBCFG); DEBUG ((EFI_D_ERROR, "DwHostInit global AHB config 0x%X\n",reg)); reg |= GAHBCFG_DMA_EN; WRITE_REG32(GAHBCFG, reg); // dwc_soft_reset(); // dwc_setup_dma_mode(); // dwc_setup_interrupts(); // status = dwc_start_xfer_scheduler(); /* if (status != USB_STATUS_SUCCESS) { dwc_power_off(); }*/ } // Compare with dwc2_hc_init() // Can we get away with just using a single channel? // after all, we only want sync request/response type // behavior.... STATIC EFI_STATUS DwChannelInit(USB_OHCI_HC_DEV *Ehc, int DevAddr, int EpNum, EFI_USB_DATA_DIRECTION EpDir, BOOLEAN Slow, UINT8 Type, UINT8 MaxPacket) { UINT32 hcchar; int channel = 0; hcchar = DevAddr << HCCHAR_DEVADDR_SHIFT & HCCHAR_DEVADDR_MASK; hcchar |= EpNum << HCCHAR_EPNUM_SHIFT & HCCHAR_EPNUM_MASK; hcchar |= Type << HCCHAR_EPTYPE_SHIFT & HCCHAR_EPTYPE_MASK; hcchar |= MaxPacket << HCCHAR_MPS_SHIFT & HCCHAR_MPS_MASK; if (EpDir == EfiUsbDataIn) { hcchar |= HCCHAR_EPDIR; } if (Slow) { hcchar |= HCCHAR_LSPDDEV; } hcchar |= (READ_REG32(HFNUM) +1) & 1; //set odd frame??? hcchar |= HCCHAR_CHENA; // enable channel, disable is already cleared WRITE_REG32(HCINT(channel), 0); //clear existing channel status WRITE_REG32(HCINTMSK(channel), 0xFFFFFFFF); //enable all status flags WRITE_REG32(HCCHAR(channel), hcchar); return EFI_SUCCESS; } /** Provides software reset for the USB host controller. @param This This EFI_USB_HC_PROTOCOL instance. @param Attributes A bit mask of the reset operation to perform. @retval EFI_SUCCESS The reset operation succeeded. @retval EFI_INVALID_PARAMETER Attributes is not valid. @retval EFI_UNSUPPOURTED The type of reset specified by Attributes is not currently supported by the host controller. @retval EFI_DEVICE_ERROR Host controller isn't halted to reset. **/ EFI_STATUS EFIAPI OhciReset ( IN EFI_USB_HC_PROTOCOL *This, IN UINT16 Attributes ) { DEBUG ((EFI_D_ERROR, "USB: OhciReset\n")); return EFI_SUCCESS; } /** Retrieve the current state of the USB host controller. @param This This EFI_USB_HC_PROTOCOL instance. @param State Variable to return the current host controller state. @retval EFI_SUCCESS Host controller state was returned in State. @retval EFI_INVALID_PARAMETER State is NULL. @retval EFI_DEVICE_ERROR An error was encountered while attempting to retrieve the host controller's current state. **/ EFI_STATUS EFIAPI OhciGetState ( IN EFI_USB_HC_PROTOCOL *This, OUT EFI_USB_HC_STATE *State ) { DEBUG ((EFI_D_ERROR, "USB: OhciGetState\n")); return EFI_SUCCESS; } /** Sets the USB host controller to a specific state. @param This This EFI_USB_HC_PROTOCOL instance. @param State The state of the host controller that will be set. @retval EFI_SUCCESS The USB host controller was successfully placed in the state specified by State. @retval EFI_INVALID_PARAMETER State is invalid. @retval EFI_DEVICE_ERROR Failed to set the state due to device error. **/ EFI_STATUS EFIAPI OhciSetState( IN EFI_USB_HC_PROTOCOL *This, IN EFI_USB_HC_STATE State ) { DEBUG ((EFI_D_ERROR, "USB: OhciSetState\n")); return EFI_SUCCESS; } /** Submits control transfer to a target USB device. @param This A pointer to the EFI_USB_HC_PROTOCOL instance. @param DeviceAddress Represents the address of the target device on the USB, which is assigned during USB enumeration. @param IsSlowDevice Indicates whether the target device is slow device or full-speed device. @param MaxPaketLength Indicates the maximum packet size that the default control transfer endpoint is capable of sending or receiving. @param Request A pointer to the USB device request that will be sent to the USB device. @param TransferDirection Specifies the data direction for the transfer. There are three values available, DataIn, DataOut and NoData. @param Data A pointer to the buffer of data that will be transmitted to USB device or received from USB device. @param DataLength Indicates the size, in bytes, of the data buffer specified by Data. @param TimeOut Indicates the maximum time, in microseconds, which the transfer is allowed to complete. @param TransferResult A pointer to the detailed result information generated by this control transfer. @retval EFI_SUCCESS The control transfer was completed successfully. @retval EFI_OUT_OF_RESOURCES The control transfer could not be completed due to a lack of resources. @retval EFI_INVALID_PARAMETER Some parameters are invalid. @retval EFI_TIMEOUT The control transfer failed due to timeout. @retval EFI_DEVICE_ERROR The control transfer failed due to host controller or device error. Caller should check TranferResult for detailed error information. --*/ void DumpRequest(EFI_USB_DEVICE_REQUEST *Request) { if (Request->RequestType & 0x80) { DEBUG ((EFI_D_ERROR, "USB: RequestType %X -> Host\n",Request->RequestType)); } else { DEBUG ((EFI_D_ERROR, "USB: RequestType %X -> Device\n",Request->RequestType)); } if (Request->RequestType & 0x60) { DEBUG ((EFI_D_ERROR, "USB: -> CLS/VEND\n")); } else { DEBUG ((EFI_D_ERROR, "USB: -> STD\n")); } switch (Request->RequestType & 0x03) { case USB_TARGET_DEVICE: DEBUG ((EFI_D_ERROR, "USB: -> DEVICE\n")); break; case USB_TARGET_INTERFACE: DEBUG ((EFI_D_ERROR, "USB: -> ITERFACE\n")); break; case USB_TARGET_ENDPOINT: DEBUG ((EFI_D_ERROR, "USB: -> ENDPOINT\n")); break; case USB_TARGET_OTHER: DEBUG ((EFI_D_ERROR, "USB: -> OTHER\n")); break; } DEBUG ((EFI_D_ERROR, "USB: RequestType 0x%X\n",Request->RequestType)); switch (Request->Request) { case USB_DEV_GET_STATUS: DEBUG ((EFI_D_ERROR, "USB: GET STATUS\n")); break; case USB_DEV_CLEAR_FEATURE: DEBUG ((EFI_D_ERROR, "USB: CLEAR FEATURE\n")); break; case USB_DEV_SET_FEATURE: DEBUG ((EFI_D_ERROR, "USB: SET FEATURE\n")); break; case USB_DEV_SET_ADDRESS: DEBUG ((EFI_D_ERROR, "USB: SET ADDRESS\n")); break; case USB_DEV_GET_DESCRIPTOR: DEBUG ((EFI_D_ERROR, "USB: GET DESCRIPTOR\n")); break; case USB_DEV_SET_DESCRIPTOR: DEBUG ((EFI_D_ERROR, "USB: SET DESCRIPTOR\n")); break; default: break; } DEBUG ((EFI_D_ERROR, "USB: Request %d\n",Request->Request)); DEBUG ((EFI_D_ERROR, "USB: Value 0x%X\n",Request->Value)); DEBUG ((EFI_D_ERROR, "USB: Index 0x%X\n",Request->Index)); DEBUG ((EFI_D_ERROR, "USB: Length %d\n",Request->Length)); } STATIC USB_DEVICE_DESCRIPTOR RootDevDescriptor = { .Length = sizeof(USB_DEVICE_DESCRIPTOR), .DescriptorType = USB_DESC_TYPE_DEVICE, .BcdUSB = 0x200, .DeviceClass = 0x09, //TYPE HUB .DeviceSubClass = 0, .DeviceProtocol = 1, .MaxPacketSize0 = 18, .IdVendor = 0, .IdProduct = 2, .BcdDevice = 0, .StrManufacturer = 0, .StrProduct = 1, .StrSerialNumber = 2, .NumConfigurations = 1 }; STATIC struct ROOT_HUB_CFG { USB_CONFIG_DESCRIPTOR RootCfgDescriptor; USB_INTERFACE_DESCRIPTOR RootIntDescriptor; USB_ENDPOINT_DESCRIPTOR RootEndDescriptor; } RootCfg = { .RootCfgDescriptor = { .Length = sizeof(USB_CONFIG_DESCRIPTOR), .DescriptorType = USB_DESC_TYPE_CONFIG, .TotalLength = sizeof(struct ROOT_HUB_CFG), .NumInterfaces = 1, .ConfigurationValue = 1, .Configuration = 0 , .Attributes = 0xC0, .MaxPower = 0 }, .RootIntDescriptor = { .Length = sizeof(USB_INTERFACE_DESCRIPTOR), .DescriptorType = USB_DESC_TYPE_INTERFACE, .InterfaceNumber = 0, .AlternateSetting = 0, .NumEndpoints = 1, .InterfaceClass = 0x09, //hub .InterfaceSubClass = 0, .InterfaceProtocol = 0, .Interface = 0 }, .RootEndDescriptor = { .Length = sizeof(USB_ENDPOINT_DESCRIPTOR), .DescriptorType = USB_DESC_TYPE_ENDPOINT, .EndpointAddress = 0x81, .Attributes = 0x03, .MaxPacketSize = 64, .Interval = 0xFF }, }; typedef struct { EFI_USB_STRING_DESCRIPTOR Hdr; CHAR16 buf[16]; } DEF_EFI_USB_STRING_DESCRIPTOR; STATIC DEF_EFI_USB_STRING_DESCRIPTOR mManufacturerStringDescriptor = { { 18, USB_DESC_TYPE_STRING, {'9'} }, {'6', 'B', 'o', 'a', 'r', 'd', 's'} }; STATIC DEF_EFI_USB_STRING_DESCRIPTOR mProductStringDescriptor = { { 12, USB_DESC_TYPE_STRING, {'H'} }, {'i', 'K', 'e', 'y'} }; STATIC DEF_EFI_USB_STRING_DESCRIPTOR mSerialStringDescriptor = { { 34, USB_DESC_TYPE_STRING, {'0'} }, {'1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'} }; EFI_STATUS EFIAPI OhciControlTransfer ( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN BOOLEAN IsSlowDevice, IN UINT8 MaxPacketLength, IN EFI_USB_DEVICE_REQUEST *Request, IN EFI_USB_DATA_DIRECTION TransferDirection, IN OUT VOID *Data OPTIONAL, IN OUT UINTN *DataLength OPTIONAL, IN UINTN TimeOut, OUT UINT32 *TransferResult ) { int handled = 0; static int first = 1; #define ENABLE_EMULATION 20 DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer (addr:%d) (direction:%d) Len:%d\n",DeviceAddress,TransferDirection,*DataLength)); DumpRequest(Request); if ((DeviceAddress == 0+ENABLE_EMULATION) && (first)) { // ignore first set addr first = 0; handled = 1; DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer, ignore first set addr for root port\n")); } if (DeviceAddress == 1+ENABLE_EMULATION) { //root port fake response if (Request->RequestType == 0x80) { //device to host if (Request->Request == USB_DEV_GET_DESCRIPTOR) { DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer get descriptor\n")); if ((Request->Value & 0xFF) == 0) { switch (Request->Value >> 8) { case USB_DESC_TYPE_DEVICE: CopyMem (Data, &RootDevDescriptor, *DataLength); handled = 1; break; case USB_DESC_TYPE_CONFIG: CopyMem (Data, &RootCfg, *DataLength); handled = 1; break; case USB_DESC_TYPE_STRING: switch (Request->Index) { case 0: CopyMem (Data, &mManufacturerStringDescriptor, *DataLength); handled = 1; break; case 1: CopyMem (Data, &mProductStringDescriptor, *DataLength); handled = 1; break; case 2: CopyMem (Data, &mSerialStringDescriptor, *DataLength); handled = 1; break; } break; } } } } if (Request->RequestType == 0) //host to device { if (Request->Request == USB_DEV_SET_CONFIGURATION) { DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer Set configuration\n")); handled = 1; } } } if (!handled) { USB_OHCI_HC_DEV *Ehc; UINT64 addr; UINT32 transfer; EFI_PHYSICAL_ADDRESS BusPhysAddr; UINTN BusLength; VOID *Mapping; EFI_STATUS Status; DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer forward to (slow=%d) (MaxTransfer=%d) bus\n",IsSlowDevice,MaxPacketLength)); Ehc = USB_OHCI_HC_DEV_FROM_THIS (This); BusLength = sizeof(EFI_USB_DEVICE_REQUEST); Status = Ehc->PciIo->Map(Ehc->PciIo, EfiPciIoOperationBusMasterRead, Request, &BusLength, &BusPhysAddr, &Mapping); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Usb: Map DMA failed\n")); } addr = BusPhysAddr; DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer 1 DMAADDR=%X BUSADDR=%X\n",Request,addr)); // Ek gad, really? Split each control transfer into its phases? (see dwc2_hc_init_xfer) // SETUP->DATA->STATUS // ASSERT(Request<32bit); WRITE_REG32(HCDMA(0), (UINT32)addr); transfer = TSIZ_SC_MC_PID_SETUP<<TSIZ_SC_MC_PID_SHIFT; transfer |= sizeof(EFI_USB_DEVICE_REQUEST)<<TSIZ_XFERSIZE_SHIFT; transfer |= 1 << TSIZ_PKTCNT_SHIFT; WRITE_REG32(HCTSIZ(0),transfer); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer 2\n")); // DwChannelInit(Ehc, DeviceAddress, 0 , EfiUsbDataIn, IsSlowDevice, USB_ENDPOINT_XFER_CONTROL, MaxPacketLength); DwChannelInit(Ehc, DeviceAddress, 0 , EfiUsbNoData, IsSlowDevice, USB_ENDPOINT_XFER_CONTROL, MaxPacketLength); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer 3\n")); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer Status = %X\n",READ_REG32(HCINT(0)))); while (READ_REG32(HCINT(0))==0); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer Status = %X pkt_remaining = %d \n",READ_REG32(HCINT(0)), READ_REG32(HCTSIZ(0)))); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer 4\n")); Status = Ehc->PciIo->Unmap (Ehc->PciIo, Mapping); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Usb: failed to Unmap DMA\n")); } // word aligned buffer can go directly to HCDMA // packet count = 1, send 'Request' // wait for complete packet if (*DataLength) { // do the data phase. BusLength = *DataLength; Mapping = NULL; Status = Ehc->PciIo->Map(Ehc->PciIo, EfiPciIoOperationBusMasterCommonBuffer , Data, &BusLength, &BusPhysAddr, &Mapping); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Usb: Map DMA failed\n")); } addr = BusPhysAddr; // addr=(UINT64)Data; DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer 6 datap=%X\n",addr)); WRITE_REG32(HCDMA(0), (UINT32)addr); transfer = TSIZ_SC_MC_PID_DATA0<<TSIZ_SC_MC_PID_SHIFT; transfer |= *DataLength<<TSIZ_XFERSIZE_SHIFT; transfer |= 1 << TSIZ_PKTCNT_SHIFT; WRITE_REG32(HCTSIZ(0),transfer); DwChannelInit(Ehc, DeviceAddress, 0 , TransferDirection, IsSlowDevice, USB_ENDPOINT_XFER_CONTROL, MaxPacketLength); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer Status = %X\n",READ_REG32(HCINT(0)))); while (READ_REG32(HCINT(0))==0); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer Status = %X pkt_remaining = %d \n",READ_REG32(HCINT(0)), READ_REG32(HCTSIZ(0)))); Status = Ehc->PciIo->Unmap (Ehc->PciIo, Mapping); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Usb: failed to Unmap DMA\n")); } } // do the status phase // status flows in the oposite direction of data if (TransferDirection == EfiUsbDataIn) { TransferDirection = EfiUsbDataOut; } else { TransferDirection = EfiUsbDataIn; } *TransferResult=0; BusLength = 4; Status = Ehc->PciIo->Map(Ehc->PciIo, EfiPciIoOperationBusMasterWrite , TransferResult , &BusLength, &BusPhysAddr, &Mapping); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Usb: Map DMA failed\n")); } addr = BusPhysAddr; // addr=(UINT64)TransferResult; WRITE_REG32(HCDMA(0), (UINT32)addr); transfer = TSIZ_SC_MC_PID_DATA1<<TSIZ_SC_MC_PID_SHIFT; transfer |= 0<<TSIZ_XFERSIZE_SHIFT; transfer |= 1 << TSIZ_PKTCNT_SHIFT; WRITE_REG32(HCTSIZ(0),transfer); DwChannelInit(Ehc, DeviceAddress, 0 , TransferDirection, IsSlowDevice, USB_ENDPOINT_XFER_CONTROL, MaxPacketLength); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer Status = %X\n",READ_REG32(HCINT(0)))); while (READ_REG32(HCINT(0))==0); Status = Ehc->PciIo->Unmap (Ehc->PciIo, Mapping); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Usb: failed to Unmap DMA\n")); } DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer Status = %X pkt_remaining = %d \n",READ_REG32(HCINT(0)), READ_REG32(HCTSIZ(0)))); DEBUG ((EFI_D_ERROR, "USB: OhciControlTransfer Status = %X tdata =%X\n",READ_REG32(HCINT(0)),*TransferResult )); // packet count = DataLength/Maxpacket (+1) send/recv 'Data' // wait from complete // (other direction for status) //DwChannelInit(Ehc, DeviceAddress, 0 , TransferDirection, IsSlowDevice, USB_ENDPOINT_XFER_CONTROL, MaxPacketLength); } return EFI_SUCCESS; } /** Submits bulk transfer to a bulk endpoint of a USB device. @param This A pointer to the EFI_USB_HC_PROTOCOL instance. @param DeviceAddress Represents the address of the target device on the USB, which is assigned during USB enumeration. @param EndPointAddress The combination of an endpoint number and an endpoint direction of the target USB device. Each endpoint address supports data transfer in one direction except the control endpoint (whose default endpoint address is 0). It is the caller's responsibility to make sure that the EndPointAddress represents a bulk endpoint. @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. @param Data A pointer to the buffer of data that will be transmitted to USB device or received from USB device. @param DataLength When input, indicates the size, in bytes, of the data buffer specified by Data. When output, indicates the actually transferred data size. @param DataToggle A pointer to the data toggle value. On input, it indicates the initial data toggle value the bulk transfer should adopt; on output, it is updated to indicate the data toggle value of the subsequent bulk transfer. @param TimeOut Indicates the maximum time, in microseconds, which the transfer is allowed to complete. TransferResult A pointer to the detailed result information of the bulk transfer. @retval EFI_SUCCESS The bulk transfer was completed successfully. @retval EFI_OUT_OF_RESOURCES The bulk transfer could not be submitted due to lack of resource. @retval EFI_INVALID_PARAMETER Some parameters are invalid. @retval EFI_TIMEOUT The bulk transfer failed due to timeout. @retval EFI_DEVICE_ERROR The bulk transfer failed due to host controller or device error. Caller should check TranferResult for detailed error information. **/ EFI_STATUS EFIAPI OhciBulkTransfer( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 MaxPacketLength, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, OUT UINT32 *TransferResult ) { DEBUG ((EFI_D_ERROR, "USB: OhciBulkTransfer\n")); return EFI_SUCCESS; } /** Submits an interrupt transfer to an interrupt endpoint of a USB device. @param Ohc Device private data @param DeviceAddress Represents the address of the target device on the USB, which is assigned during USB enumeration. @param EndPointAddress The combination of an endpoint number and an endpoint direction of the target USB device. Each endpoint address supports data transfer in one direction except the control endpoint (whose default endpoint address is 0). It is the caller's responsibility to make sure that the EndPointAddress represents an interrupt endpoint. @param IsSlowDevice Indicates whether the target device is slow device or full-speed device. @param MaxPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between the host and the target interrupt endpoint. If FALSE, the specified asynchronous interrupt pipe is canceled. @param DataToggle A pointer to the data toggle value. On input, it is valid when IsNewTransfer is TRUE, and it indicates the initial data toggle value the asynchronous interrupt transfer should adopt. On output, it is valid when IsNewTransfer is FALSE, and it is updated to indicate the data toggle value of the subsequent asynchronous interrupt transfer. @param PollingInterval Indicates the interval, in milliseconds, that the asynchronous interrupt transfer is polled. This parameter is required when IsNewTransfer is TRUE. @param UCBuffer Uncacheable buffer @param DataLength Indicates the length of data to be received at the rate specified by PollingInterval from the target asynchronous interrupt endpoint. This parameter is only required when IsNewTransfer is TRUE. @param CallBackFunction The Callback function.This function is called at the rate specified by PollingInterval.This parameter is only required when IsNewTransfer is TRUE. @param Context The context that is passed to the CallBackFunction. This is an optional parameter and may be NULL. @param IsPeriodic Periodic interrupt or not @param OutputED The correspoding ED carried out @param OutputTD The correspoding TD carried out @retval EFI_SUCCESS The asynchronous interrupt transfer request has been successfully submitted or canceled. @retval EFI_INVALID_PARAMETER Some parameters are invalid. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. **/ EFI_STATUS OhciInterruptTransfer ( IN USB_OHCI_HC_DEV *Ohc, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN BOOLEAN IsSlowDevice, IN UINT8 MaxPacketLength, IN BOOLEAN IsNewTransfer, IN OUT UINT8 *DataToggle OPTIONAL, IN UINTN PollingInterval OPTIONAL, IN VOID *UCBuffer OPTIONAL, IN UINTN DataLength OPTIONAL, IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, IN VOID *Context OPTIONAL, IN BOOLEAN IsPeriodic OPTIONAL, OUT VOID **OutputED OPTIONAL, OUT VOID **OutputTD OPTIONAL ) { DEBUG ((EFI_D_ERROR, "USB: OhciInterruptTransfer\n")); return EFI_SUCCESS; } /** Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device. @param This A pointer to the EFI_USB_HC_PROTOCOL instance. @param DeviceAddress Represents the address of the target device on the USB, which is assigned during USB enumeration. @param EndPointAddress The combination of an endpoint number and an endpoint direction of the target USB device. Each endpoint address supports data transfer in one direction except the control endpoint (whose default endpoint address is 0). It is the caller's responsibility to make sure that the EndPointAddress represents an interrupt endpoint. @param IsSlowDevice Indicates whether the target device is slow device or full-speed device. @param MaxiumPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between the host and the target interrupt endpoint. If FALSE, the specified asynchronous interrupt pipe is canceled. @param DataToggle A pointer to the data toggle value. On input, it is valid when IsNewTransfer is TRUE, and it indicates the initial data toggle value the asynchronous interrupt transfer should adopt. On output, it is valid when IsNewTransfer is FALSE, and it is updated to indicate the data toggle value of the subsequent asynchronous interrupt transfer. @param PollingInterval Indicates the interval, in milliseconds, that the asynchronous interrupt transfer is polled. This parameter is required when IsNewTransfer is TRUE. @param DataLength Indicates the length of data to be received at the rate specified by PollingInterval from the target asynchronous interrupt endpoint. This parameter is only required when IsNewTransfer is TRUE. @param CallBackFunction The Callback function.This function is called at the rate specified by PollingInterval.This parameter is only required when IsNewTransfer is TRUE. @param Context The context that is passed to the CallBackFunction. This is an optional parameter and may be NULL. @retval EFI_SUCCESS The asynchronous interrupt transfer request has been successfully submitted or canceled. @retval EFI_INVALID_PARAMETER Some parameters are invalid. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. **/ EFI_STATUS EFIAPI OhciAsyncInterruptTransfer ( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN BOOLEAN IsSlowDevice, IN UINT8 MaxPacketLength, IN BOOLEAN IsNewTransfer, IN OUT UINT8 *DataToggle OPTIONAL, IN UINTN PollingInterval OPTIONAL, IN UINTN DataLength OPTIONAL, IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, IN VOID *Context OPTIONAL ) { DEBUG ((EFI_D_ERROR, "USB: OhciAsyncInterruptTransfer\n")); return EFI_SUCCESS; } /** Submits synchronous interrupt transfer to an interrupt endpoint of a USB device. @param This A pointer to the EFI_USB_HC_PROTOCOL instance. @param DeviceAddress Represents the address of the target device on the USB, which is assigned during USB enumeration. @param EndPointAddress The combination of an endpoint number and an endpoint direction of the target USB device. Each endpoint address supports data transfer in one direction except the control endpoint (whose default endpoint address is 0). It is the caller's responsibility to make sure that the EndPointAddress represents an interrupt endpoint. @param IsSlowDevice Indicates whether the target device is slow device or full-speed device. @param MaxPacketLength Indicates the maximum packet size the target endpoint is capable of sending or receiving. @param Data A pointer to the buffer of data that will be transmitted to USB device or received from USB device. @param DataLength On input, the size, in bytes, of the data buffer specified by Data. On output, the number of bytes transferred. @param DataToggle A pointer to the data toggle value. On input, it indicates the initial data toggle value the synchronous interrupt transfer should adopt; on output, it is updated to indicate the data toggle value of the subsequent synchronous interrupt transfer. @param TimeOut Indicates the maximum time, in microseconds, which the transfer is allowed to complete. @param TransferResult A pointer to the detailed result information from the synchronous interrupt transfer. @retval EFI_UNSUPPORTED This interface not available. @retval EFI_INVALID_PARAMETER Parameters not follow spec **/ EFI_STATUS EFIAPI OhciSyncInterruptTransfer ( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN BOOLEAN IsSlowDevice, IN UINT8 MaxPacketLength, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, OUT UINT32 *TransferResult ) { DEBUG ((EFI_D_ERROR, "USB: OhciSyncInterruptTransfer\n")); return EFI_SUCCESS; } /** Submits isochronous transfer to a target USB device. @param This A pointer to the EFI_USB_HC_PROTOCOL instance. @param DeviceAddress Represents the address of the target device on the USB, which is assigned during USB enumeration. @param EndPointAddress End point address @param MaximumPacketLength Indicates the maximum packet size that the default control transfer endpoint is capable of sending or receiving. @param Data A pointer to the buffer of data that will be transmitted to USB device or received from USB device. @param DataLength Indicates the size, in bytes, of the data buffer specified by Data. @param TransferResult A pointer to the detailed result information generated by this control transfer. @retval EFI_UNSUPPORTED This interface not available @retval EFI_INVALID_PARAMETER Data is NULL or DataLength is 0 or TransferResult is NULL **/ EFI_STATUS EFIAPI OhciIsochronousTransfer ( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 MaximumPacketLength, IN OUT VOID *Data, IN OUT UINTN DataLength, OUT UINT32 *TransferResult ) { DEBUG ((EFI_D_ERROR, "USB: OhciIsochronousTransfer\n")); if (Data == NULL || DataLength == 0 || TransferResult == NULL) { return EFI_INVALID_PARAMETER; } return EFI_UNSUPPORTED; } /** Submits Async isochronous transfer to a target USB device. @param his A pointer to the EFI_USB_HC_PROTOCOL instance. @param DeviceAddress Represents the address of the target device on the USB, which is assigned during USB enumeration. @param EndPointAddress End point address @param MaximumPacketLength Indicates the maximum packet size that the default control transfer endpoint is capable of sending or receiving. @param Data A pointer to the buffer of data that will be transmitted to USB device or received from USB device. @param IsochronousCallBack When the transfer complete, the call back function will be called @param Context Pass to the call back function as parameter @retval EFI_UNSUPPORTED This interface not available @retval EFI_INVALID_PARAMETER Data is NULL or Datalength is 0 **/ EFI_STATUS EFIAPI OhciAsyncIsochronousTransfer ( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 MaximumPacketLength, IN OUT VOID *Data, IN OUT UINTN DataLength, IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, IN VOID *Context OPTIONAL ) { DEBUG ((EFI_D_ERROR, "USB: OhciAsyncIsochronousTransfer\n")); if (Data == NULL || DataLength == 0) { return EFI_INVALID_PARAMETER; } return EFI_UNSUPPORTED; } /** Retrieves the number of root hub ports. @param This A pointer to the EFI_USB_HC_PROTOCOL instance. @param NumOfPorts A pointer to the number of the root hub ports. @retval EFI_SUCCESS The port number was retrieved successfully. **/ EFI_STATUS EFIAPI OhciGetRootHubNumOfPorts ( IN EFI_USB_HC_PROTOCOL *This, OUT UINT8 *NumOfPorts ) { DEBUG ((EFI_D_ERROR, "USB: OhciGetRootHubNumOfPorts\n")); //TODO, so apparently this devices root port can't be probed? // default to one port, and simulate it? *NumOfPorts = 1; return EFI_SUCCESS; } #define MAXPORTS 4; /** Retrieves the current status of a USB root hub port. @param This A pointer to the EFI_USB_HC_PROTOCOL. @param PortNumber Specifies the root hub port from which the status is to be retrieved. This value is zero-based. For example, if a root hub has two ports, then the first port is numbered 0, and the second port is numbered 1. @param PortStatus A pointer to the current port status bits and port status change bits. @retval EFI_SUCCESS The status of the USB root hub port specified by PortNumber was returned in PortStatus. @retval EFI_INVALID_PARAMETER Port number not valid **/ EFI_STATUS EFIAPI OhciGetRootHubPortStatus ( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 PortNumber, OUT EFI_USB_PORT_STATUS *PortStatus ) { USB_OHCI_HC_DEV *Ehc; // DEBUG ((EFI_D_ERROR, "USB: OhciGetRootHubPortStatus %d\n",PortNumber)); if (PortStatus == NULL) { return EFI_INVALID_PARAMETER; } Ehc = USB_OHCI_HC_DEV_FROM_THIS (This); //TODO more faked status? // The HPRT register contains the host status // indicating speed/power etc PortStatus->PortStatus = 0; PortStatus->PortChangeStatus = 0; PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED; PortStatus->PortStatus |= USB_PORT_STAT_ENABLE; PortStatus->PortStatus |= USB_PORT_STAT_POWER; PortStatus->PortStatus |= USB_PORT_STAT_CONNECTION; // on first status (reset/whatever) describe a new connection if (Ehc->PortStatus) { DEBUG ((EFI_D_ERROR, "USB: OhciGetRootHubPortStatus %d change to connected\n",PortNumber)); DEBUG ((EFI_D_ERROR, "USB: OhciGetRootHubPortStatus actual hport status %X\n",READ_REG32(HPRT))); Ehc->PortStatus = 0; PortStatus->PortChangeStatus |= USB_PORT_STAT_CONNECTION; } return EFI_SUCCESS; } /** Sets a feature for the specified root hub port. @param This A pointer to the EFI_USB_HC_PROTOCOL. @param PortNumber Specifies the root hub port whose feature is requested to be set. @param PortFeature Indicates the feature selector associated with the feature set request. @retval EFI_SUCCESS The feature specified by PortFeature was set for the USB root hub port specified by PortNumber. @retval EFI_DEVICE_ERROR Set feature failed because of hardware issue @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid. **/ EFI_STATUS EFIAPI OhciSetRootHubPortFeature ( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature ) { DEBUG ((EFI_D_ERROR, "USB: OhciSetRootHubPortFeature port(%d) -> %d\n",PortNumber,PortFeature)); switch (PortFeature) { case EfiUsbPortReset: DEBUG ((EFI_D_ERROR, "USB: OhciSetRootHubPortFeature reset\n")); break; case EfiUsbPortEnable: DEBUG ((EFI_D_ERROR, "USB: OhciSetRootHubPortFeature enable\n")); break; default: DEBUG ((EFI_D_ERROR, "USB: OhciSetRootHubPortFeature (other)\n")); } return EFI_SUCCESS; } /** Clears a feature for the specified root hub port. @param This A pointer to the EFI_USB_HC_PROTOCOL instance. @param PortNumber Specifies the root hub port whose feature is requested to be cleared. @param PortFeature Indicates the feature selector associated with the feature clear request. @retval EFI_SUCCESS The feature specified by PortFeature was cleared for the USB root hub port specified by PortNumber. @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid. @retval EFI_DEVICE_ERROR Some error happened when clearing feature **/ EFI_STATUS EFIAPI OhciClearRootHubPortFeature ( IN EFI_USB_HC_PROTOCOL *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature ) { DEBUG ((EFI_D_ERROR, "USB: OhciClearRootHubPortFeature port(%d) -> %d\n",PortNumber,PortFeature)); return EFI_SUCCESS; } USB_OHCI_HC_DEV * OhciAllocateDev ( IN EFI_PCI_IO_PROTOCOL *PciIo ) { USB_OHCI_HC_DEV *Ohc; // EFI_STATUS Status; // VOID *Buf; // EFI_PHYSICAL_ADDRESS PhyAddr; // VOID *Map; UINTN Pages; UINTN Bytes; Ohc = AllocateZeroPool (sizeof (USB_OHCI_HC_DEV)); if (Ohc == NULL) { return NULL; } Ohc->Signature = USB_DW_HC_DEV_SIGNATURE; Ohc->PciIo = PciIo; Ohc->UsbHc.Reset = OhciReset; Ohc->UsbHc.GetState = OhciGetState; Ohc->UsbHc.SetState = OhciSetState; Ohc->UsbHc.ControlTransfer = OhciControlTransfer; Ohc->UsbHc.BulkTransfer = OhciBulkTransfer; Ohc->UsbHc.AsyncInterruptTransfer = OhciAsyncInterruptTransfer; Ohc->UsbHc.SyncInterruptTransfer = OhciSyncInterruptTransfer; Ohc->UsbHc.IsochronousTransfer = OhciIsochronousTransfer; Ohc->UsbHc.AsyncIsochronousTransfer = OhciAsyncIsochronousTransfer; Ohc->UsbHc.GetRootHubPortNumber = OhciGetRootHubNumOfPorts; Ohc->UsbHc.GetRootHubPortStatus = OhciGetRootHubPortStatus; Ohc->UsbHc.SetRootHubPortFeature = OhciSetRootHubPortFeature; Ohc->UsbHc.ClearRootHubPortFeature = OhciClearRootHubPortFeature; Ohc->UsbHc.MajorRevision = 0x1; Ohc->UsbHc.MinorRevision = 0x1; // Ohc->HccaMemoryBlock = NULL; Ohc->HccaMemoryMapping = NULL; Ohc->HccaMemoryBuf = NULL; Ohc->HccaMemoryPages = 0; // Ohc->InterruptContextList = NULL; Ohc->ControllerNameTable = NULL; Ohc->HouseKeeperTimer = NULL; /* Ohc->MemPool = UsbHcInitMemPool(PciIo, TRUE, 0); if(Ohc->MemPool == NULL) { goto FREE_DEV_BUFFER; }*/ Bytes = 4096; Pages = EFI_SIZE_TO_PAGES (Bytes); /* Status = PciIo->AllocateBuffer ( PciIo, AllocateAnyPages, EfiBootServicesData, Pages, &Buf, 0 ); if (EFI_ERROR (Status)) { goto FREE_MEM_POOL; } Status = PciIo->Map ( PciIo, EfiPciIoOperationBusMasterCommonBuffer, Buf, &Bytes, &PhyAddr, &Map ); if (EFI_ERROR (Status) || (Bytes != 4096)) { goto FREE_MEM_PAGE; }*/ // Ohc->HccaMemoryBlock = (HCCA_MEMORY_BLOCK *)(UINTN)PhyAddr; // Ohc->HccaMemoryMapping = Map; // Ohc->HccaMemoryBuf = (VOID *)(UINTN)Buf; Ohc->HccaMemoryPages = Pages; Ohc->PortStatus = 1; return Ohc; //FREE_MEM_PAGE: // PciIo->FreeBuffer (PciIo, Pages, Buf); //FREE_MEM_POOL: // UsbHcFreeMemPool (Ohc->MemPool); //FREE_DEV_BUFFER: // FreePool(Ohc); return NULL; } /** One notified function to stop the Host Controller when gBS->ExitBootServices() called. @param Event Pointer to this event @param Context Event handler private data **/ VOID EFIAPI DwHcExitBootService ( EFI_EVENT Event, VOID *Context ) { DEBUG ((EFI_D_ERROR, "DwUsbExitBootService!\n")); } #pragma pack(1) typedef struct { UINT8 ProgInterface; UINT8 SubClassCode; UINT8 BaseCode; } USB_CLASSC; #pragma pack() //typedef struct _USB2_HC_DEV USB2_HC_DEV; /** Test to see if this driver supports ControllerHandle. Any ControllerHandle that has Usb2HcProtocol installed will be supported. @param This Protocol instance pointer. @param Controller Handle of device to test. @param RemainingDevicePath Not used. @return EFI_SUCCESS This driver supports this device. @return EFI_UNSUPPORTED This driver does not support this device. **/ EFI_STATUS EFIAPI DwUsbDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { EFI_STATUS Status; EFI_PCI_IO_PROTOCOL *PciIo; USB_CLASSC UsbClassCReg; // DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingSupported\n")); // // Test whether there is PCI IO Protocol attached on the controller handle. // Status = gBS->OpenProtocol ( Controller, &gEfiPciIoProtocolGuid, (VOID **) &PciIo, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status)) { return EFI_UNSUPPORTED; } Status = PciIo->Pci.Read ( PciIo, EfiPciIoWidthUint8, PCI_CLASSCODE_OFFSET, sizeof (USB_CLASSC) / sizeof (UINT8), &UsbClassCReg ); if (EFI_ERROR (Status)) { Status = EFI_UNSUPPORTED; goto ON_EXIT; } // // Test whether the controller belongs to Usb class type // if ((UsbClassCReg.BaseCode != PCI_CLASS_SERIAL) || (UsbClassCReg.SubClassCode != PCI_CLASS_SERIAL_USB)) { Status = EFI_UNSUPPORTED; } else { DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingSupported found board!\n")); } ON_EXIT: gBS->CloseProtocol ( Controller, &gEfiPciIoProtocolGuid, This->DriverBindingHandle, Controller ); return Status; } /** Starting the Usb EHCI Driver. @param This Protocol instance pointer. @param Controller Handle of device to test. @param RemainingDevicePath Not used. @return EFI_SUCCESS supports this device. @return EFI_UNSUPPORTED do not support this device. @return EFI_DEVICE_ERROR cannot be started due to device Error. @return EFI_OUT_OF_RESOURCES cannot allocate resources. **/ EFI_STATUS EFIAPI DwUsbDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { EFI_STATUS Status; // USB2_HC_DEV *Ehc; USB_OHCI_HC_DEV *Ehc; EFI_PCI_IO_PROTOCOL *PciIo; EFI_DEVICE_PATH_PROTOCOL *HcDevicePath; DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart \n")); // // Open the PciIo Protocol, then enable the USB host controller // Status = gBS->OpenProtocol ( Controller, &gEfiPciIoProtocolGuid, (VOID **) &PciIo, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER ); if (EFI_ERROR (Status)) { return Status; } DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart2 \n")); // // Open Device Path Protocol for on USB host controller // HcDevicePath = NULL; Status = gBS->OpenProtocol ( Controller, &gEfiDevicePathProtocolGuid, (VOID **) &HcDevicePath, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart3 \n")); // // Create then install USB2_HC_PROTOCOL // // Ehc = EhcCreateUsb2Hc (PciIo, HcDevicePath, OriginalPciAttributes); // Ehc = EhcCreateUsb2Hc (PciIo, HcDevicePath, 0); Ehc = OhciAllocateDev(PciIo); DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart4 \n")); if (Ehc == NULL) { DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to create USB2_HC\n")); Status = EFI_OUT_OF_RESOURCES; goto CLOSE_PCIIO; } Status = gBS->InstallProtocolInterface ( &Controller, // &gEfiUsb2HcProtocolGuid, &gEfiUsbHcProtocolGuid, EFI_NATIVE_INTERFACE, &Ehc->UsbHc ); DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart5 \n")); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to install USB2_HC Protocol\n")); goto FREE_POOL; } // // Start the asynchronous interrupt monitor // /* Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_INTERVAL); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to start async interrupt monitor\n")); EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT); goto UNINSTALL_USBHC; } */ // // Create event to stop the HC when exit boot service. // Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, DwHcExitBootService, Ehc, &gEfiEventExitBootServicesGuid, &Ehc->ExitBootServiceEvent ); if (EFI_ERROR (Status)) { goto UNINSTALL_USBHC; } // // Install the component name protocol, don't fail the start // because of something for display. // DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart6 \n")); AddUnicodeString2 ( "eng", gOhciComponentName.SupportedLanguages, &Ehc->ControllerNameTable, L"Designware Host Controller (USB 2.0)", TRUE ); AddUnicodeString2 ( "en", gOhciComponentName2.SupportedLanguages, &Ehc->ControllerNameTable, L"Designware Host Controller (USB 2.0)", FALSE ); DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart7 \n")); phy_init(Ehc); //TODO these need the pci protocol so they talk to the right device... DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart8 \n")); DwHostInit(Ehc); UNINSTALL_USBHC: CLOSE_PCIIO: FREE_POOL: DEBUG ((EFI_D_INFO, "EhcDriverBindingStart: EHCI started for controller @ %p\n", Controller)); DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStart9 \n")); return EFI_SUCCESS; } /** Stop this driver on ControllerHandle. Support stopping any child handles created by this driver. @param This Protocol instance pointer. @param Controller Handle of device to stop driver on. @param NumberOfChildren Number of Children in the ChildHandleBuffer. @param ChildHandleBuffer List of handles for the children we need to stop. @return EFI_SUCCESS Success. @return EFI_DEVICE_ERROR Fail. **/ EFI_STATUS EFIAPI DwUsbDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ) { EFI_STATUS Status; EFI_USB2_HC_PROTOCOL *Usb2Hc; // EFI_PCI_IO_PROTOCOL *PciIo; USB_OHCI_HC_DEV *Ehc; DEBUG ((EFI_D_ERROR, "DwUsbDriverBindingStop \n")); // // Test whether the Controller handler passed in is a valid // Usb controller handle that should be supported, if not, // return the error status directly // Status = gBS->OpenProtocol ( Controller, // &gEfiUsb2HcProtocolGuid, &gEfiUsbHcProtocolGuid, (VOID **) &Usb2Hc, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return Status; } // Ehc = EHC_FROM_THIS (Usb2Hc); Ehc = USB_OHCI_HC_DEV_FROM_THIS (This); // PciIo = Ehc->PciIo; Status = gBS->UninstallProtocolInterface ( Controller, // &gEfiUsb2HcProtocolGuid, &gEfiUsbHcProtocolGuid, Usb2Hc ); if (EFI_ERROR (Status)) { return Status; } // // Stop AsyncRequest Polling timer then stop the EHCI driver // and uninstall the EHCI protocl. // /* gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_INTERVAL); EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT); if (Ehc->PollTimer != NULL) { gBS->CloseEvent (Ehc->PollTimer); } */ if (Ehc->ExitBootServiceEvent != NULL) { gBS->CloseEvent (Ehc->ExitBootServiceEvent); } /* EhcFreeSched (Ehc); if (Ehc->ControllerNameTable != NULL) { FreeUnicodeStringTable (Ehc->ControllerNameTable); } */ // // Disable routing of all ports to EHCI controller, so all ports are // routed back to the UHCI or OHCI controller. // /*EhcClearOpRegBit (Ehc, EHC_CONFIG_FLAG_OFFSET, CONFIGFLAG_ROUTE_EHC); // // Restore original PCI attributes // PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationSet, Ehc->OriginalPciAttributes, NULL ); */ gBS->CloseProtocol ( Controller, &gEfiPciIoProtocolGuid, This->DriverBindingHandle, Controller ); FreePool (Ehc); return EFI_SUCCESS; } EFI_DRIVER_BINDING_PROTOCOL gOhciDriverBinding = { DwUsbDriverBindingSupported, DwUsbDriverBindingStart, DwUsbDriverBindingStop, 0x30, NULL, NULL }; EFI_STATUS EFIAPI DwUsbEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { DEBUG ((EFI_D_ERROR, "DwUsbEntryPoint \n")); return EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gOhciDriverBinding, ImageHandle, &gOhciComponentName, &gOhciComponentName2 ); }
jlinton/OpenPlatformPkg
Drivers/Usb/DwUsbDxe/DwUsbDxe.c
C
bsd-2-clause
78,599
/**************************************************************************** * arch/arm/src/armv7-m/cache.h * * Copyright (C) 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Some logic in this header file derives from the ARM CMSIS core_cm7.h * header file which has a compatible 3-clause BSD license: * * Copyright (c) 2009 - 2014 ARM LIMITED. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. Neither the name ARM, NuttX 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 OWNER 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 __ARCH_ARM_SRC_ARMV7_M_CACHE_H #define __ARCH_ARM_SRC_ARMV7_M_CACHE_H /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include "up_arch.h" #include "nvic.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* Cache Size ID (CCSIDR) register macros used by inline functions * Given the value of the CCSIDR reginer (n): * * CCSIDR_WAYS - Returns the (number of ways) - 1 * CCSIDR_SETS - Returns the (number of sets) - 1 * CCSIDR_LSSHIFT - Returns log2(cache line size in words) - 2 * Eg. 0 -> 4 words * 1 -> 8 words * ... */ #define CCSIDR_WAYS(n) \ (((n) & NVIC_CCSIDR_ASSOCIATIVITY_MASK) >> NVIC_CCSIDR_ASSOCIATIVITY_SHIFT) #define CCSIDR_SETS(n) \ (((n) & NVIC_CCSIDR_NUMSETS_MASK) >> NVIC_CCSIDR_NUMSETS_SHIFT) #define CCSIDR_LSSHIFT(n) \ (((n) & NVIC_CCSIDR_LINESIZE_MASK) >> NVIC_CCSIDR_LINESIZE_SHIFT) /* intrinsics are used in these inline functions */ #define arm_isb(n) __asm__ __volatile__ ("isb " #n : : : "memory") #define arm_dsb(n) __asm__ __volatile__ ("dsb " #n : : : "memory") #define ARM_DSB() arm_dsb(15) #define ARM_ISB() arm_isb(15) /**************************************************************************** * Inline Functions ****************************************************************************/ #ifndef __ASSEMBLY__ /**************************************************************************** * Name: arm_clz * * Description: * Access to CLZ instructions * * Input Parameters: * value - The value to perform the CLZ operation on * * Returned Value: * None * ****************************************************************************/ static inline uint32_t arm_clz(unsigned int value) { uint32_t ret; __asm__ __volatile__ ("clz %0, %1" : "=r"(ret) : "r"(value)); return ret; } /**************************************************************************** * Name: arch_enable_icache * * Description: * Enable the I-Cache * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ static inline void arch_enable_icache(void) { #ifdef CONFIG_ARMV7M_ICACHE uint32_t regval; ARM_DSB(); ARM_ISB(); /* Invalidate the entire I-Cache */ putreg32(0, NVIC_ICIALLU); /* Enable the I-Cache */ regval = getreg32(NVIC_CFGCON); regval |= NVIC_CFGCON_IC; putreg32(regval, NVIC_CFGCON); ARM_DSB(); ARM_ISB(); #endif } /**************************************************************************** * Name: arch_disable_icache * * Description: * Disable the I-Cache * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ static inline void arch_disable_icache(void) { #ifdef CONFIG_ARMV7M_ICACHE uint32_t regval; ARM_DSB(); ARM_ISB(); /* Disable the I-Cache */ regval = getreg32(NVIC_CFGCON); regval &= ~NVIC_CFGCON_IC; putreg32(regval, NVIC_CFGCON); /* Invalidate the entire I-Cache */ putreg32(0, NVIC_ICIALLU); ARM_DSB(); ARM_ISB(); #endif } /**************************************************************************** * Name: arch_invalidate_icache_all * * Description: * Invalidate the entire contents of I cache. * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ static inline void arch_invalidate_icache_all(void) { #ifdef CONFIG_ARMV7M_ICACHE ARM_DSB(); ARM_ISB(); /* Invalidate the entire I-Cache */ putreg32(0, NVIC_ICIALLU); ARM_DSB(); ARM_ISB(); #endif } /**************************************************************************** * Name: arch_dcache_writethrough * * Description: * Configure the D-Cache for Write-Through operation. * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ #if defined(CONFIG_ARMV7M_DCACHE) && defined(CONFIG_ARMV7M_DCACHE_WRITETHROUGH) static inline void arch_dcache_writethrough(void) { uint32_t regval = getreg32(NVIC_CACR); regval |= NVIC_CACR_FORCEWT; putreg32(regval, NVIC_CACR); } #else # define arch_dcache_writethrough() #endif /**************************************************************************** * Public Variables ****************************************************************************/ #ifdef __cplusplus #define EXTERN extern "C" extern "C" { #else #define EXTERN extern #endif /**************************************************************************** * Public Function Prototypes ****************************************************************************/ /**************************************************************************** * Name: arch_enable_dcache * * Description: * Enable the D-Cache * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ #ifdef CONFIG_ARMV7M_DCACHE void arch_enable_dcache(void); #else # define arch_enable_dcache() #endif /**************************************************************************** * Name: arch_disable_dcache * * Description: * Disable the D-Cache * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ #ifdef CONFIG_ARMV7M_DCACHE void arch_disable_dcache(void); #else # define arch_disable_dcache() #endif /**************************************************************************** * Name: arch_invalidate_dcache * * Description: * Invalidate the data cache within the specified region; we will be * performing a DMA operation in this region and we want to purge old data * in the cache. * * Input Parameters: * start - virtual start address of region * end - virtual end address of region + 1 * * Returned Value: * None * * Assumptions: * This operation is not atomic. This function assumes that the caller * has exclusive access to the address range so that no harm is done if * the operation is pre-empted. * ****************************************************************************/ #ifdef CONFIG_ARMV7M_DCACHE void arch_invalidate_dcache(uintptr_t start, uintptr_t end); #else # define arch_invalidate_dcache(s,e) #endif /**************************************************************************** * Name: arch_invalidate_dcache_all * * Description: * Invalidate the entire contents of D cache. * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ #ifdef CONFIG_ARMV7M_DCACHE void arch_invalidate_dcache_all(void); #else # define arch_invalidate_dcache_all() #endif /**************************************************************************** * Name: arch_clean_dcache * * Description: * Clean the data cache within the specified region by flushing the * contents of the data cache to memory. * * NOTE: This operation is un-necessary if the DCACHE is configured in * write-through mode. * * Input Parameters: * start - virtual start address of region * end - virtual end address of region + 1 * * Returned Value: * None * * Assumptions: * This operation is not atomic. This function assumes that the caller * has exclusive access to the address range so that no harm is done if * the operation is pre-empted. * ****************************************************************************/ #if defined(CONFIG_ARMV7M_DCACHE) && !defined(CONFIG_ARMV7M_DCACHE_WRITETHROUGH) void arch_clean_dcache(uintptr_t start, uintptr_t end); #else # define arch_clean_dcache(s,e) #endif /**************************************************************************** * Name: arch_clean_dcache_all * * Description: * Clean the entire data cache within the specified region by flushing the * contents of the data cache to memory. * * NOTE: This operation is un-necessary if the DCACHE is configured in * write-through mode. * * Input Parameters: * None * * Returned Value: * None * * Assumptions: * This operation is not atomic. This function assumes that the caller * has exclusive access to the address range so that no harm is done if * the operation is pre-empted. * ****************************************************************************/ #if defined(CONFIG_ARMV7M_DCACHE) && !defined(CONFIG_ARMV7M_DCACHE_WRITETHROUGH) void arch_clean_dcache_all(void); #else # define arch_clean_dcache_all() #endif /**************************************************************************** * Name: arch_flush_dcache * * Description: * Flush the data cache within the specified region by cleaning and * invalidating the D cache. * * NOTE: If DCACHE write-through is configured, then this operation is the * same as arch_invalidate_cache(). * * Input Parameters: * start - virtual start address of region * end - virtual end address of region + 1 * * Returned Value: * None * * Assumptions: * This operation is not atomic. This function assumes that the caller * has exclusive access to the address range so that no harm is done if * the operation is pre-empted. * ****************************************************************************/ #ifdef CONFIG_ARMV7M_DCACHE #ifdef CONFIG_ARMV7M_DCACHE_WRITETHROUGH # define arch_flush_dcache(s,e) arch_invalidate_dcache(s,e) #else void arch_flush_dcache(uintptr_t start, uintptr_t end); #endif #else # define arch_flush_dcache(s,e) #endif /**************************************************************************** * Name: arch_flush_dcache_all * * Description: * Flush the entire data cache by cleaning and invalidating the D cache. * * NOTE: If DCACHE write-through is configured, then this operation is the * same as arch_invalidate_cache_all(). * * Input Parameters: * None * * Returned Value: * None * * Assumptions: * This operation is not atomic. This function assumes that the caller * has exclusive access to the address range so that no harm is done if * the operation is pre-empted. * ****************************************************************************/ #ifdef CONFIG_ARMV7M_DCACHE #ifdef CONFIG_ARMV7M_DCACHE_WRITETHROUGH # define arch_flush_dcache_all() arch_invalidate_dcache_all() #else void arch_flush_dcache_all(void); #endif #else # define arch_flush_dcache_all() #endif #undef EXTERN #ifdef __cplusplus } #endif #endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_SRC_ARMV7_M_CACHE_H */
IUTInfoAix/terrarium_2015
nuttx/arch/arm/src/armv7-m/cache.h
C
bsd-2-clause
13,070
//================================================================================================= /*! // \file blaze/math/expressions/DMatDMatMultExpr.h // \brief Header file for the dense matrix/dense matrix multiplication expression // // Copyright (C) 2012-2017 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. 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. // 3. Neither the names of the Blaze development group 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 _BLAZE_MATH_EXPRESSIONS_DMATDMATMULTEXPR_H_ #define _BLAZE_MATH_EXPRESSIONS_DMATDMATMULTEXPR_H_ //************************************************************************************************* // Includes //************************************************************************************************* #include <blaze/math/blas/gemm.h> #include <blaze/math/blas/trmm.h> #include <blaze/math/Aliases.h> #include <blaze/math/constraints/ColumnMajorMatrix.h> #include <blaze/math/constraints/DenseMatrix.h> #include <blaze/math/constraints/MatMatMultExpr.h> #include <blaze/math/constraints/RequiresEvaluation.h> #include <blaze/math/constraints/RowMajorMatrix.h> #include <blaze/math/constraints/StorageOrder.h> #include <blaze/math/constraints/Symmetric.h> #include <blaze/math/dense/MMM.h> #include <blaze/math/Exception.h> #include <blaze/math/expressions/Computation.h> #include <blaze/math/expressions/DenseMatrix.h> #include <blaze/math/expressions/DenseVector.h> #include <blaze/math/expressions/Forward.h> #include <blaze/math/expressions/MatMatMultExpr.h> #include <blaze/math/expressions/MatScalarMultExpr.h> #include <blaze/math/expressions/SparseVector.h> #include <blaze/math/functors/DeclDiag.h> #include <blaze/math/functors/DeclHerm.h> #include <blaze/math/functors/DeclLow.h> #include <blaze/math/functors/DeclSym.h> #include <blaze/math/functors/DeclUpp.h> #include <blaze/math/functors/Noop.h> #include <blaze/math/shims/Conjugate.h> #include <blaze/math/shims/Reset.h> #include <blaze/math/shims/Serial.h> #include <blaze/math/SIMD.h> #include <blaze/math/traits/MultTrait.h> #include <blaze/math/typetraits/Columns.h> #include <blaze/math/typetraits/HasConstDataAccess.h> #include <blaze/math/typetraits/HasMutableDataAccess.h> #include <blaze/math/typetraits/HasSIMDAdd.h> #include <blaze/math/typetraits/HasSIMDMult.h> #include <blaze/math/typetraits/IsAligned.h> #include <blaze/math/typetraits/IsBLASCompatible.h> #include <blaze/math/typetraits/IsColumnMajorMatrix.h> #include <blaze/math/typetraits/IsComputation.h> #include <blaze/math/typetraits/IsDiagonal.h> #include <blaze/math/typetraits/IsExpression.h> #include <blaze/math/typetraits/IsLower.h> #include <blaze/math/typetraits/IsResizable.h> #include <blaze/math/typetraits/IsSIMDCombinable.h> #include <blaze/math/typetraits/IsStrictlyLower.h> #include <blaze/math/typetraits/IsStrictlyTriangular.h> #include <blaze/math/typetraits/IsStrictlyUpper.h> #include <blaze/math/typetraits/IsSymmetric.h> #include <blaze/math/typetraits/IsTriangular.h> #include <blaze/math/typetraits/IsUniLower.h> #include <blaze/math/typetraits/IsUniUpper.h> #include <blaze/math/typetraits/IsUpper.h> #include <blaze/math/typetraits/RequiresEvaluation.h> #include <blaze/math/typetraits/Rows.h> #include <blaze/system/BLAS.h> #include <blaze/system/Blocking.h> #include <blaze/system/Debugging.h> #include <blaze/system/Optimizations.h> #include <blaze/system/Thresholds.h> #include <blaze/util/algorithms/Max.h> #include <blaze/util/algorithms/Min.h> #include <blaze/util/Assert.h> #include <blaze/util/Complex.h> #include <blaze/util/constraints/Numeric.h> #include <blaze/util/constraints/SameType.h> #include <blaze/util/DisableIf.h> #include <blaze/util/EnableIf.h> #include <blaze/util/FunctionTrace.h> #include <blaze/util/IntegralConstant.h> #include <blaze/util/InvalidType.h> #include <blaze/util/mpl/And.h> #include <blaze/util/mpl/Bool.h> #include <blaze/util/mpl/If.h> #include <blaze/util/mpl/Not.h> #include <blaze/util/mpl/Or.h> #include <blaze/util/TrueType.h> #include <blaze/util/Types.h> #include <blaze/util/typetraits/IsBuiltin.h> #include <blaze/util/typetraits/IsComplex.h> #include <blaze/util/typetraits/IsComplexDouble.h> #include <blaze/util/typetraits/IsComplexFloat.h> #include <blaze/util/typetraits/IsDouble.h> #include <blaze/util/typetraits/IsFloat.h> #include <blaze/util/typetraits/IsIntegral.h> #include <blaze/util/typetraits/IsSame.h> namespace blaze { //================================================================================================= // // CLASS DMATDMATMULTEXPR // //================================================================================================= //************************************************************************************************* /*!\brief Expression object for dense matrix-dense matrix multiplications. // \ingroup dense_matrix_expression // // The DMatDMatMultExpr class represents the compile time expression for multiplications between // row-major dense matrices. */ template< typename MT1 // Type of the left-hand side dense matrix , typename MT2 // Type of the right-hand side dense matrix , bool SF // Symmetry flag , bool HF // Hermitian flag , bool LF // Lower flag , bool UF > // Upper flag class DMatDMatMultExpr : public MatMatMultExpr< DenseMatrix< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, false > > , private Computation { private: //**Type definitions**************************************************************************** using RT1 = ResultType_<MT1>; //!< Result type of the left-hand side dense matrix expression. using RT2 = ResultType_<MT2>; //!< Result type of the right-hand side dense matrix expression. using ET1 = ElementType_<RT1>; //!< Element type of the left-hand side dense matrix expression. using ET2 = ElementType_<RT2>; //!< Element type of the right-hand side dense matrix expression. using CT1 = CompositeType_<MT1>; //!< Composite type of the left-hand side dense matrix expression. using CT2 = CompositeType_<MT2>; //!< Composite type of the right-hand side dense matrix expression. //********************************************************************************************** //********************************************************************************************** //! Compilation switch for the composite type of the left-hand side dense matrix expression. enum : bool { evaluateLeft = IsComputation<MT1>::value || RequiresEvaluation<MT1>::value }; //********************************************************************************************** //********************************************************************************************** //! Compilation switch for the composite type of the right-hand side dense matrix expression. enum : bool { evaluateRight = IsComputation<MT2>::value || RequiresEvaluation<MT2>::value }; //********************************************************************************************** //********************************************************************************************** //! Compilation switches for the kernel generation. enum : bool { SYM = ( SF && !( HF || LF || UF ) ), //!< Flag for symmetric matrices. HERM = ( HF && !( LF || UF ) ), //!< Flag for Hermitian matrices. LOW = ( LF || ( ( SF || HF ) && UF ) ), //!< Flag for lower matrices. UPP = ( UF || ( ( SF || HF ) && LF ) ) //!< Flag for upper matrices. }; //********************************************************************************************** //********************************************************************************************** /*! \cond BLAZE_INTERNAL */ //! Helper structure for the explicit application of the SFINAE principle. /*! The CanExploitSymmetry struct is a helper struct for the selection of the optimal evaluation strategy. In case the target matrix is column-major and either of the two matrix operands is symmetric, \a value is set to 1 and an optimized evaluation strategy is selected. Otherwise \a value is set to 0 and the default strategy is chosen. */ template< typename T1, typename T2, typename T3 > struct CanExploitSymmetry { enum : bool { value = IsColumnMajorMatrix<T1>::value && ( IsSymmetric<T2>::value || IsSymmetric<T3>::value ) }; }; /*! \endcond */ //********************************************************************************************** //********************************************************************************************** /*! \cond BLAZE_INTERNAL */ //! Helper structure for the explicit application of the SFINAE principle. /*! The IsEvaluationRequired struct is a helper struct for the selection of the parallel evaluation strategy. In case either of the two matrix operands requires an intermediate evaluation, the nested \value will be set to 1, otherwise it will be 0. */ template< typename T1, typename T2, typename T3 > struct IsEvaluationRequired { enum : bool { value = ( evaluateLeft || evaluateRight ) && !CanExploitSymmetry<T1,T2,T3>::value }; }; /*! \endcond */ //********************************************************************************************** //********************************************************************************************** /*! \cond BLAZE_INTERNAL */ //! Helper structure for the explicit application of the SFINAE principle. /*! In case the types of all three involved matrices are suited for a BLAS kernel, the nested \a value will be set to 1, otherwise it will be 0. */ template< typename T1, typename T2, typename T3 > struct UseBlasKernel { enum : bool { value = BLAZE_BLAS_MODE && BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION && !SYM && !HERM && !LOW && !UPP && HasMutableDataAccess<T1>::value && HasConstDataAccess<T2>::value && HasConstDataAccess<T3>::value && !IsDiagonal<T2>::value && !IsDiagonal<T3>::value && T1::simdEnabled && T2::simdEnabled && T3::simdEnabled && IsBLASCompatible< ElementType_<T1> >::value && IsBLASCompatible< ElementType_<T2> >::value && IsBLASCompatible< ElementType_<T3> >::value && IsSame< ElementType_<T1>, ElementType_<T2> >::value && IsSame< ElementType_<T1>, ElementType_<T3> >::value }; }; /*! \endcond */ //********************************************************************************************** //********************************************************************************************** /*! \cond BLAZE_INTERNAL */ //! Helper structure for the explicit application of the SFINAE principle. /*! In case all three involved data types are suited for a vectorized computation of the matrix multiplication, the nested \value will be set to 1, otherwise it will be 0. */ template< typename T1, typename T2, typename T3 > struct UseVectorizedDefaultKernel { enum : bool { value = useOptimizedKernels && !IsDiagonal<T2>::value && !IsDiagonal<T3>::value && T1::simdEnabled && T2::simdEnabled && T3::simdEnabled && IsSIMDCombinable< ElementType_<T1> , ElementType_<T2> , ElementType_<T3> >::value && HasSIMDAdd< ElementType_<T2>, ElementType_<T3> >::value && HasSIMDMult< ElementType_<T2>, ElementType_<T3> >::value }; }; /*! \endcond */ //********************************************************************************************** //********************************************************************************************** /*! \cond BLAZE_INTERNAL */ //! Type of the functor for forwarding an expression to another assign kernel. /*! In case a temporary matrix needs to be created, this functor is used to forward the resulting expression to another assign kernel. */ using ForwardFunctor = IfTrue_< HERM , DeclHerm , IfTrue_< SYM , DeclSym , IfTrue_< LOW , IfTrue_< UPP , DeclDiag , DeclLow > , IfTrue_< UPP , DeclUpp , Noop > > > >; /*! \endcond */ //********************************************************************************************** public: //**Type definitions**************************************************************************** //! Type of this DMatDMatMultExpr instance. using This = DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>; using ResultType = MultTrait_<RT1,RT2>; //!< Result type for expression template evaluations. using OppositeType = OppositeType_<ResultType>; //!< Result type with opposite storage order for expression template evaluations. using TransposeType = TransposeType_<ResultType>; //!< Transpose type for expression template evaluations. using ElementType = ElementType_<ResultType>; //!< Resulting element type. using SIMDType = SIMDTrait_<ElementType>; //!< Resulting SIMD element type. using ReturnType = const ElementType; //!< Return type for expression template evaluations. using CompositeType = const ResultType; //!< Data type for composite expression templates. //! Composite type of the left-hand side dense matrix expression. using LeftOperand = If_< IsExpression<MT1>, const MT1, const MT1& >; //! Composite type of the right-hand side dense matrix expression. using RightOperand = If_< IsExpression<MT2>, const MT2, const MT2& >; //! Type for the assignment of the left-hand side dense matrix operand. using LT = IfTrue_< evaluateLeft, const RT1, CT1 >; //! Type for the assignment of the right-hand side dense matrix operand. using RT = IfTrue_< evaluateRight, const RT2, CT2 >; //********************************************************************************************** //**Compilation flags*************************************************************************** //! Compilation switch for the expression template evaluation strategy. enum : bool { simdEnabled = !IsDiagonal<MT2>::value && MT1::simdEnabled && MT2::simdEnabled && HasSIMDAdd<ET1,ET2>::value && HasSIMDMult<ET1,ET2>::value }; //! Compilation switch for the expression template assignment strategy. enum : bool { smpAssignable = !evaluateLeft && MT1::smpAssignable && !evaluateRight && MT2::smpAssignable }; //********************************************************************************************** //**SIMD properties***************************************************************************** //! The number of elements packed within a single SIMD element. enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size }; //********************************************************************************************** //**Constructor********************************************************************************* /*!\brief Constructor for the DMatDMatMultExpr class. // // \param lhs The left-hand side operand of the multiplication expression. // \param rhs The right-hand side operand of the multiplication expression. */ explicit inline DMatDMatMultExpr( const MT1& lhs, const MT2& rhs ) noexcept : lhs_( lhs ) // Left-hand side dense matrix of the multiplication expression , rhs_( rhs ) // Right-hand side dense matrix of the multiplication expression { BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.rows(), "Invalid matrix sizes" ); } //********************************************************************************************** //**Access operator***************************************************************************** /*!\brief 2D-access to the matrix elements. // // \param i Access index for the row. The index has to be in the range \f$[0..M-1]\f$. // \param j Access index for the column. The index has to be in the range \f$[0..N-1]\f$. // \return The resulting value. */ inline ReturnType operator()( size_t i, size_t j ) const { BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" ); BLAZE_INTERNAL_ASSERT( j < rhs_.columns(), "Invalid column access index" ); if( IsDiagonal<MT1>::value ) { return lhs_(i,i) * rhs_(i,j); } else if( IsDiagonal<MT2>::value ) { return lhs_(i,j) * rhs_(j,j); } else if( IsTriangular<MT1>::value || IsTriangular<MT2>::value ) { const size_t begin( ( IsUpper<MT1>::value ) ?( ( IsLower<MT2>::value ) ?( max( ( IsStrictlyUpper<MT1>::value ? i+1UL : i ) , ( IsStrictlyLower<MT2>::value ? j+1UL : j ) ) ) :( IsStrictlyUpper<MT1>::value ? i+1UL : i ) ) :( ( IsLower<MT2>::value ) ?( IsStrictlyLower<MT2>::value ? j+1UL : j ) :( 0UL ) ) ); const size_t end( ( IsLower<MT1>::value ) ?( ( IsUpper<MT2>::value ) ?( min( ( IsStrictlyLower<MT1>::value ? i : i+1UL ) , ( IsStrictlyUpper<MT2>::value ? j : j+1UL ) ) ) :( IsStrictlyLower<MT1>::value ? i : i+1UL ) ) :( ( IsUpper<MT2>::value ) ?( IsStrictlyUpper<MT2>::value ? j : j+1UL ) :( lhs_.columns() ) ) ); if( begin >= end ) return ElementType(); const size_t n( end - begin ); return subvector( row( lhs_, i ), begin, n ) * subvector( column( rhs_, j ), begin, n ); } else { return row( lhs_, i ) * column( rhs_, j ); } } //********************************************************************************************** //**At function********************************************************************************* /*!\brief Checked access to the matrix elements. // // \param i Access index for the row. The index has to be in the range \f$[0..M-1]\f$. // \param j Access index for the column. The index has to be in the range \f$[0..N-1]\f$. // \return The resulting value. // \exception std::out_of_range Invalid matrix access index. */ inline ReturnType at( size_t i, size_t j ) const { if( i >= lhs_.rows() ) { BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" ); } if( j >= rhs_.columns() ) { BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" ); } return (*this)(i,j); } //********************************************************************************************** //**Rows function******************************************************************************* /*!\brief Returns the current number of rows of the matrix. // // \return The number of rows of the matrix. */ inline size_t rows() const noexcept { return lhs_.rows(); } //********************************************************************************************** //**Columns function**************************************************************************** /*!\brief Returns the current number of columns of the matrix. // // \return The number of columns of the matrix. */ inline size_t columns() const noexcept { return rhs_.columns(); } //********************************************************************************************** //**Left operand access************************************************************************* /*!\brief Returns the left-hand side dense matrix operand. // // \return The left-hand side dense matrix operand. */ inline LeftOperand leftOperand() const noexcept { return lhs_; } //********************************************************************************************** //**Right operand access************************************************************************ /*!\brief Returns the right-hand side dense matrix operand. // // \return The right-hand side dense matrix operand. */ inline RightOperand rightOperand() const noexcept { return rhs_; } //********************************************************************************************** //********************************************************************************************** /*!\brief Returns whether the expression can alias with the given address \a alias. // // \param alias The alias to be checked. // \return \a true in case the expression can alias, \a false otherwise. */ template< typename T > inline bool canAlias( const T* alias ) const noexcept { return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) ); } //********************************************************************************************** //********************************************************************************************** /*!\brief Returns whether the expression is aliased with the given address \a alias. // // \param alias The alias to be checked. // \return \a true in case an alias effect is detected, \a false otherwise. */ template< typename T > inline bool isAliased( const T* alias ) const noexcept { return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) ); } //********************************************************************************************** //********************************************************************************************** /*!\brief Returns whether the operands of the expression are properly aligned in memory. // // \return \a true in case the operands are aligned, \a false if not. */ inline bool isAligned() const noexcept { return lhs_.isAligned() && rhs_.isAligned(); } //********************************************************************************************** //********************************************************************************************** /*!\brief Returns whether the expression can be used in SMP assignments. // // \return \a true in case the expression can be used in SMP assignments, \a false if not. */ inline bool canSMPAssign() const noexcept { return ( !BLAZE_BLAS_MODE || !BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION || !BLAZE_BLAS_IS_PARALLEL || ( rows() * columns() < DMATDMATMULT_THRESHOLD ) ) && ( rows() * columns() >= SMP_DMATDMATMULT_THRESHOLD ) && !IsDiagonal<MT1>::value && !IsDiagonal<MT2>::value; } //********************************************************************************************** private: //**Member variables**************************************************************************** LeftOperand lhs_; //!< Left-hand side dense matrix of the multiplication expression. RightOperand rhs_; //!< Right-hand side dense matrix of the multiplication expression. //********************************************************************************************** //**Assignment to dense matrices**************************************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Assignment of a dense matrix-dense matrix multiplication to a dense matrix // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side multiplication expression to be assigned. // \return void // // This function implements the performance optimized assignment of a dense matrix-dense // matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> > assign( DenseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL ) { return; } else if( rhs.lhs_.columns() == 0UL ) { reset( ~lhs ); return; } LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" ); DMatDMatMultExpr::selectAssignKernel( ~lhs, A, B ); } /*! \endcond */ //********************************************************************************************** //**Assignment to dense matrices (kernel selection)********************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Selection of the kernel for an assignment of a dense matrix-dense matrix // multiplication to a dense matrix (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline void selectAssignKernel( MT3& C, const MT4& A, const MT5& B ) { if( ( IsDiagonal<MT5>::value ) || ( !BLAZE_DEBUG_MODE && B.columns() <= SIMDSIZE*10UL ) || ( C.rows() * C.columns() < DMATDMATMULT_THRESHOLD ) ) selectSmallAssignKernel( C, A, B ); else selectBlasAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Default assignment to dense matrices (general/general)************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default assignment of a general dense matrix-general dense matrix multiplication // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default assignment of a general dense matrix-general dense // matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< Not< IsDiagonal<MT4> >, Not< IsDiagonal<MT5> > > > selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B ) { const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( SYM || HERM || LOW || UPP ) || ( M == N ), "Broken invariant detected" ); for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( K ) ); BLAZE_INTERNAL_ASSERT( kbegin <= kend, "Invalid loop indices detected" ); if( IsStrictlyTriangular<MT4>::value && kbegin == kend ) { for( size_t j=0UL; j<N; ++j ) { reset( C(i,j) ); } continue; } { const size_t jbegin( ( IsUpper<MT5>::value ) ?( ( IsStrictlyUpper<MT5>::value ) ?( UPP ? max(i,kbegin+1UL) : kbegin+1UL ) :( UPP ? max(i,kbegin) : kbegin ) ) :( UPP ? i : 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( ( IsStrictlyLower<MT5>::value ) ?( LOW ? min(i+1UL,kbegin) : kbegin ) :( LOW ? min(i,kbegin)+1UL : kbegin+1UL ) ) :( LOW ? i+1UL : N ) ); if( ( IsUpper<MT4>::value && IsUpper<MT5>::value ) || UPP ) { for( size_t j=0UL; j<jbegin; ++j ) { reset( C(i,j) ); } } else if( IsStrictlyUpper<MT5>::value ) { reset( C(i,0UL) ); } for( size_t j=jbegin; j<jend; ++j ) { C(i,j) = A(i,kbegin) * B(kbegin,j); } if( ( IsLower<MT4>::value && IsLower<MT5>::value ) || LOW ) { for( size_t j=jend; j<N; ++j ) { reset( C(i,j) ); } } else if( IsStrictlyLower<MT5>::value ) { reset( C(i,N-1UL) ); } } for( size_t k=kbegin+1UL; k<kend; ++k ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( ( IsStrictlyUpper<MT5>::value ) ?( SYM || HERM || UPP ? max( i, k+1UL ) : k+1UL ) :( SYM || HERM || UPP ? max( i, k ) : k ) ) :( SYM || HERM || UPP ? i : 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( ( IsStrictlyLower<MT5>::value ) ?( LOW ? min(i+1UL,k-1UL) : k-1UL ) :( LOW ? min(i+1UL,k) : k ) ) :( LOW ? i+1UL : N ) ); if( ( SYM || HERM || LOW || UPP ) && ( jbegin > jend ) ) continue; BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); for( size_t j=jbegin; j<jend; ++j ) { C(i,j) += A(i,k) * B(k,j); } if( IsLower<MT5>::value ) { C(i,jend) = A(i,k) * B(k,jend); } } } if( SYM || HERM ) { for( size_t i=1UL; i<M; ++i ) { for( size_t j=0UL; j<i; ++j ) { C(i,j) = HERM ? conj( C(j,i) ) : C(j,i); } } } } /*! \endcond */ //********************************************************************************************** //**Default assignment to dense matrices (general/diagonal)************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Default assignment of a general dense matrix-diagonal dense matrix multiplication // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default assignment of a general dense matrix-diagonal dense // matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< Not< IsDiagonal<MT4> >, IsDiagonal<MT5> > > selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); if( IsUpper<MT4>::value ) { for( size_t j=0UL; j<jbegin; ++j ) { reset( C(i,j) ); } } for( size_t j=jbegin; j<jend; ++j ) { C(i,j) = A(i,j) * B(j,j); } if( IsLower<MT4>::value ) { for( size_t j=jend; j<N; ++j ) { reset( C(i,j) ); } } } } /*! \endcond */ //********************************************************************************************** //**Default assignment to dense matrices (diagonal/general)************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Default assignment of a diagonal dense matrix-general dense matrix multiplication // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default assignment of a diagonal dense matrix-general dense // matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< IsDiagonal<MT4>, Not< IsDiagonal<MT5> > > > selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( IsStrictlyUpper<MT5>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( IsStrictlyLower<MT5>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); if( IsUpper<MT5>::value ) { for( size_t j=0UL; j<jbegin; ++j ) { reset( C(i,j) ); } } for( size_t j=jbegin; j<jend; ++j ) { C(i,j) = A(i,i) * B(i,j); } if( IsLower<MT5>::value ) { for( size_t j=jend; j<N; ++j ) { reset( C(i,j) ); } } } } /*! \endcond */ //********************************************************************************************** //**Default assignment to dense matrices (diagonal/diagonal)************************************ /*! \cond BLAZE_INTERNAL */ /*!\brief Default assignment of a diagonal dense matrix-diagonal dense matrix multiplication // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default assignment of a diagonal dense matrix-diagonal dense // matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< IsDiagonal<MT4>, IsDiagonal<MT5> > > selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); reset( C ); for( size_t i=0UL; i<A.rows(); ++i ) { C(i,i) = A(i,i) * B(i,i); } } /*! \endcond */ //********************************************************************************************** //**Default assignment to dense matrices (small matrices)*************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default assignment of a small dense matrix-dense matrix multiplication (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the assignment of a dense matrix- // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectDefaultAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Vectorized default assignment to row-major dense matrices (small matrices)****************** /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default assignment of a small dense matrix-dense matrix multiplication // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default assignment of a dense matrix-dense matrix // multiplication expression to a row-major dense matrix. This kernel is optimized for small // matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallAssignKernel( DenseMatrix<MT3,false>& C, const MT4& A, const MT5& B ) { constexpr bool remainder( !IsPadded<MT3>::value || !IsPadded<MT5>::value ); const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( SYM || HERM || LOW || UPP ) || ( M == N ), "Broken invariant detected" ); const size_t jpos( remainder ? ( N & size_t(-SIMDSIZE) ) : N ); BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % SIMDSIZE ) ) == jpos, "Invalid end calculation" ); if( LOW && UPP && N > SIMDSIZE*3UL ) { reset( ~C ); } { size_t j( 0UL ); if( IsIntegral<ElementType>::value ) { for( ; !SYM && !HERM && !LOW && !UPP && (j+SIMDSIZE*7UL) < jpos; j+=SIMDSIZE*8UL ) { for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i : i+1UL ), j+SIMDSIZE*8UL, K ) ) :( IsStrictlyLower<MT4>::value ? i : i+1UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*8UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); xmm6 += a1 * B.load(k,j+SIMDSIZE*5UL); xmm7 += a1 * B.load(k,j+SIMDSIZE*6UL); xmm8 += a1 * B.load(k,j+SIMDSIZE*7UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); (~C).store( i, j+SIMDSIZE*4UL, xmm5 ); (~C).store( i, j+SIMDSIZE*5UL, xmm6 ); (~C).store( i, j+SIMDSIZE*6UL, xmm7 ); (~C).store( i, j+SIMDSIZE*7UL, xmm8 ); } } } for( ; !SYM && !HERM && !LOW && !UPP && (j+SIMDSIZE*4UL) < jpos; j+=SIMDSIZE*5UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*5UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*5UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); const SIMDType b5( B.load(k,j+SIMDSIZE*4UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a1 * b5; xmm6 += a2 * b1; xmm7 += a2 * b2; xmm8 += a2 * b3; xmm9 += a2 * b4; xmm10 += a2 * b5; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i , j+SIMDSIZE*3UL, xmm4 ); (~C).store( i , j+SIMDSIZE*4UL, xmm5 ); (~C).store( i+1UL, j , xmm6 ); (~C).store( i+1UL, j+SIMDSIZE , xmm7 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm8 ); (~C).store( i+1UL, j+SIMDSIZE*3UL, xmm9 ); (~C).store( i+1UL, j+SIMDSIZE*4UL, xmm10 ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*5UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); (~C).store( i, j+SIMDSIZE*4UL, xmm5 ); } } for( ; !( LOW && UPP ) && (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) { const size_t iend( SYM || HERM || UPP ? min(j+SIMDSIZE*4UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*4UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*4UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a2 * b1; xmm6 += a2 * b2; xmm7 += a2 * b3; xmm8 += a2 * b4; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i , j+SIMDSIZE*3UL, xmm4 ); (~C).store( i+1UL, j , xmm5 ); (~C).store( i+1UL, j+SIMDSIZE , xmm6 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm7 ); (~C).store( i+1UL, j+SIMDSIZE*3UL, xmm8 ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*4UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); } } for( ; (j+SIMDSIZE*2UL) < jpos; j+=SIMDSIZE*3UL ) { const size_t iend( SYM || HERM || UPP ? min(j+SIMDSIZE*3UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*3UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*3UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a2 * b1; xmm5 += a2 * b2; xmm6 += a2 * b3; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i+1UL, j , xmm4 ); (~C).store( i+1UL, j+SIMDSIZE , xmm5 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm6 ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*3UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); } } for( ; (j+SIMDSIZE) < jpos; j+=SIMDSIZE*2UL ) { const size_t iend( SYM || HERM || UPP ? min(j+SIMDSIZE*2UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType a4( set( A(i+3UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; xmm7 += a4 * b1; xmm8 += a4 * b2; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE, xmm2 ); (~C).store( i+1UL, j , xmm3 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4 ); (~C).store( i+2UL, j , xmm5 ); (~C).store( i+2UL, j+SIMDSIZE, xmm6 ); (~C).store( i+3UL, j , xmm7 ); (~C).store( i+3UL, j+SIMDSIZE, xmm8 ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE, xmm2 ); (~C).store( i+1UL, j , xmm3 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4 ); (~C).store( i+2UL, j , xmm5 ); (~C).store( i+2UL, j+SIMDSIZE, xmm6 ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i ,k ) ) ); const SIMDType a2( set( A(i+1UL,k ) ) ); const SIMDType a3( set( A(i ,k+1UL) ) ); const SIMDType a4( set( A(i+1UL,k+1UL) ) ); const SIMDType b1( B.load(k ,j ) ); const SIMDType b2( B.load(k ,j+SIMDSIZE) ); const SIMDType b3( B.load(k+1UL,j ) ); const SIMDType b4( B.load(k+1UL,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b3; xmm6 += a3 * b4; xmm7 += a4 * b3; xmm8 += a4 * b4; } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; } (~C).store( i , j , xmm1+xmm5 ); (~C).store( i , j+SIMDSIZE, xmm2+xmm6 ); (~C).store( i+1UL, j , xmm3+xmm7 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4+xmm8 ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*2UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i,k ) ) ); const SIMDType a2( set( A(i,k+1UL) ) ); xmm1 += a1 * B.load(k ,j ); xmm2 += a1 * B.load(k ,j+SIMDSIZE); xmm3 += a2 * B.load(k+1UL,j ); xmm4 += a2 * B.load(k+1UL,j+SIMDSIZE); } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE); } (~C).store( i, j , xmm1+xmm3 ); (~C).store( i, j+SIMDSIZE, xmm2+xmm4 ); } } for( ; j<jpos; j+=SIMDSIZE ) { const size_t iend( SYM || HERM || UPP ? min(j+SIMDSIZE,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i+3UL,k ) ) * b1; xmm5 += set( A(i ,k+1UL) ) * b2; xmm6 += set( A(i+1UL,k+1UL) ) * b2; xmm7 += set( A(i+2UL,k+1UL) ) * b2; xmm8 += set( A(i+3UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; xmm4 += set( A(i+3UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm5 ); (~C).store( i+1UL, j, xmm2+xmm6 ); (~C).store( i+2UL, j, xmm3+xmm7 ); (~C).store( i+3UL, j, xmm4+xmm8 ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i ,k+1UL) ) * b2; xmm5 += set( A(i+1UL,k+1UL) ) * b2; xmm6 += set( A(i+2UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm4 ); (~C).store( i+1UL, j, xmm2+xmm5 ); (~C).store( i+2UL, j, xmm3+xmm6 ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i ,k+1UL) ) * b2; xmm4 += set( A(i+1UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm3 ); (~C).store( i+1UL, j, xmm2+xmm4 ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); SIMDType xmm1, xmm2; size_t k( kbegin ); for( ; (k+2UL) <= K; k+=2UL ) { xmm1 += set( A(i,k ) ) * B.load(k ,j); xmm2 += set( A(i,k+1UL) ) * B.load(k+1UL,j); } for( ; k<K; ++k ) { xmm1 += set( A(i,k) ) * B.load(k,j); } (~C).store( i, j, xmm1+xmm2 ); } } for( ; remainder && j<N; ++j ) { size_t i( LOW && UPP ? j : 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); ElementType value1 = ElementType(); ElementType value2 = ElementType(); for( size_t k=kbegin; k<kend; ++k ) { value1 += A(i ,k) * B(k,j); value2 += A(i+1UL,k) * B(k,j); } (~C)(i ,j) = value1; (~C)(i+1UL,j) = value2; } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); ElementType value = ElementType(); for( size_t k=kbegin; k<K; ++k ) { value += A(i,k) * B(k,j); } (~C)(i,j) = value; } } } if( ( SYM || HERM ) && ( N > SIMDSIZE*4UL ) ) { for( size_t i=SIMDSIZE*4UL; i<M; ++i ) { const size_t jend( ( SIMDSIZE*4UL ) * ( i / (SIMDSIZE*4UL) ) ); for( size_t j=0UL; j<jend; ++j ) { (~C)(i,j) = HERM ? conj( (~C)(j,i) ) : (~C)(j,i); } } } else if( LOW && !UPP && N > SIMDSIZE*4UL ) { for( size_t j=SIMDSIZE*4UL; j<N; ++j ) { const size_t iend( ( SIMDSIZE*4UL ) * ( j / (SIMDSIZE*4UL) ) ); for( size_t i=0UL; i<iend; ++i ) { reset( (~C)(i,j) ); } } } else if( !LOW && UPP && N > SIMDSIZE*4UL ) { for( size_t i=SIMDSIZE*4UL; i<M; ++i ) { const size_t jend( ( SIMDSIZE*4UL ) * ( i / (SIMDSIZE*4UL) ) ); for( size_t j=0UL; j<jend; ++j ) { reset( (~C)(i,j) ); } } } } /*! \endcond */ //********************************************************************************************** //**Vectorized default assignment to column-major dense matrices (small matrices)*************** /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default assignment of a small dense matrix-dense matrix multiplication // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default assignment of a dense matrix-dense matrix // multiplication expression to a column-major dense matrix. This kernel is optimized for small // matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallAssignKernel( DenseMatrix<MT3,true>& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT4 ); BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT5 ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT4> ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT5> ); const ForwardFunctor fwd; if( !IsResizable<MT4>::value && IsResizable<MT5>::value ) { const OppositeType_<MT4> tmp( serial( A ) ); assign( ~C, fwd( tmp * B ) ); } else if( IsResizable<MT4>::value && !IsResizable<MT5>::value ) { const OppositeType_<MT5> tmp( serial( B ) ); assign( ~C, fwd( A * tmp ) ); } else if( A.rows() * A.columns() <= B.rows() * B.columns() ) { const OppositeType_<MT4> tmp( serial( A ) ); assign( ~C, fwd( tmp * B ) ); } else { const OppositeType_<MT5> tmp( serial( B ) ); assign( ~C, fwd( A * tmp ) ); } } /*! \endcond */ //********************************************************************************************** //**Default assignment to dense matrices (large matrices)*************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default assignment of a large dense matrix-dense matrix multiplication (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the assignment of a dense matrix- // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectDefaultAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Vectorized default assignment to dense matrices (large matrices)**************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default assignment of a large dense matrix-dense matrix multiplication // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default assignment of a dense matrix-dense matrix // multiplication expression to a dense matrix. This kernel is optimized for large matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B ) { if( SYM ) smmm( C, A, B, ElementType(1) ); else if( HERM ) hmmm( C, A, B, ElementType(1) ); else if( LOW ) lmmm( C, A, B, ElementType(1), ElementType(0) ); else if( UPP ) ummm( C, A, B, ElementType(1), ElementType(0) ); else mmm( C, A, B, ElementType(1), ElementType(0) ); } /*! \endcond */ //********************************************************************************************** //**BLAS-based assignment to dense matrices (default)******************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Default assignment of a dense matrix-dense matrix multiplication (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the assignment of a large dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseBlasKernel<MT3,MT4,MT5> > selectBlasAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectLargeAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**BLAS-based assignment to dense matrices***************************************************** #if BLAZE_BLAS_MODE && BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION /*! \cond BLAZE_INTERNAL */ /*!\brief BLAS-based assignment of a dense matrix-dense matrix multiplication (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function performs the dense matrix-dense matrix multiplication based on the according // BLAS functionality. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseBlasKernel<MT3,MT4,MT5> > selectBlasAssignKernel( MT3& C, const MT4& A, const MT5& B ) { using ET = ElementType_<MT3>; if( IsTriangular<MT4>::value ) { assign( C, B ); trmm( C, A, CblasLeft, ( IsLower<MT4>::value )?( CblasLower ):( CblasUpper ), ET(1) ); } else if( IsTriangular<MT5>::value ) { assign( C, A ); trmm( C, B, CblasRight, ( IsLower<MT5>::value )?( CblasLower ):( CblasUpper ), ET(1) ); } else { gemm( C, A, B, ET(1), ET(0) ); } } /*! \endcond */ #endif //********************************************************************************************** //**Assignment to sparse matrices*************************************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Assignment of a dense matrix-dense matrix multiplication to a sparse matrix // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side sparse matrix. // \param rhs The right-hand side multiplication expression to be assigned. // \return void // // This function implements the performance optimized assignment of a dense matrix-dense // matrix multiplication expression to a sparse matrix. */ template< typename MT // Type of the target sparse matrix , bool SO > // Storage order of the target sparse matrix friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> > assign( SparseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; using TmpType = IfTrue_< SO, OppositeType, ResultType >; BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( OppositeType ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType ); BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER( MT, TmpType ); BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( TmpType ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; const TmpType tmp( serial( rhs ) ); assign( ~lhs, fwd( tmp ) ); } /*! \endcond */ //********************************************************************************************** //**Restructuring assignment to column-major matrices******************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Restructuring assignment of a dense matrix-dense matrix multiplication to a // column-major matrix (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side multiplication expression to be assigned. // \return void // // This function implements the symmetry-based restructuring assignment of a dense matrix- // dense matrix multiplication expression to a column-major matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler // in case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > assign( Matrix<MT,true>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) assign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) ); else if( IsSymmetric<MT1>::value ) assign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) ); else assign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) ); } /*! \endcond */ //********************************************************************************************** //**Addition assignment to dense matrices******************************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Addition assignment of a dense matrix-dense matrix multiplication to a dense matrix // (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side multiplication expression to be added. // \return void // // This function implements the performance optimized addition assignment of a dense matrix- // dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> > addAssign( DenseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL || rhs.lhs_.columns() == 0UL ) { return; } LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" ); DMatDMatMultExpr::selectAddAssignKernel( ~lhs, A, B ); } /*! \endcond */ //********************************************************************************************** //**Addition assignment to dense matrices (kernel selection)************************************ /*! \cond BLAZE_INTERNAL */ /*!\brief Selection of the kernel for an addition assignment of a dense matrix-dense matrix // multiplication to a dense matrix (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline void selectAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { if( ( IsDiagonal<MT5>::value ) || ( !BLAZE_DEBUG_MODE && B.columns() <= SIMDSIZE*10UL ) || ( C.rows() * C.columns() < DMATDMATMULT_THRESHOLD ) ) selectSmallAddAssignKernel( C, A, B ); else selectBlasAddAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Default addition assignment to dense matrices (general/general)***************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default addition assignment of a general dense matrix-general dense matrix // multiplication (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default addition assignment of a general dense matrix-general // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< Not< IsDiagonal<MT4> >, Not< IsDiagonal<MT5> > > > selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( LOW || UPP ) || ( M == N ), "Broken invariant detected" ); for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( K ) ); BLAZE_INTERNAL_ASSERT( kbegin <= kend, "Invalid loop indices detected" ); for( size_t k=kbegin; k<kend; ++k ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( ( IsStrictlyUpper<MT5>::value ) ?( UPP ? max(i,k+1UL) : k+1UL ) :( UPP ? max(i,k) : k ) ) :( UPP ? i : 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( ( IsStrictlyLower<MT5>::value ) ?( LOW ? min(i+1UL,k) : k ) :( LOW ? min(i,k)+1UL : k+1UL ) ) :( LOW ? i+1UL : N ) ); if( ( LOW || UPP ) && ( jbegin >= jend ) ) continue; BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) += A(i,k) * B(k,j ); C(i,j+1UL) += A(i,k) * B(k,j+1UL); } if( jpos < jend ) { C(i,jpos) += A(i,k) * B(k,jpos); } } } } /*! \endcond */ //********************************************************************************************** //**Default addition assignment to dense matrices (general/diagonal)**************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default addition assignment of a general dense matrix-diagonal dense matrix // multiplication (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default addition assignment of a general dense matrix-diagonal // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< Not< IsDiagonal<MT4> >, IsDiagonal<MT5> > > selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) += A(i,j ) * B(j ,j ); C(i,j+1UL) += A(i,j+1UL) * B(j+1UL,j+1UL); } if( jpos < jend ) { C(i,jpos) += A(i,jpos) * B(jpos,jpos); } } } /*! \endcond */ //********************************************************************************************** //**Default addition assignment to dense matrices (diagonal/general)**************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default addition assignment of a diagonal dense matrix-general dense matrix // multiplication (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default addition assignment of a diagonal dense matrix-general // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< IsDiagonal<MT4>, Not< IsDiagonal<MT5> > > > selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( IsStrictlyUpper<MT5>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( IsStrictlyLower<MT5>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) += A(i,i) * B(i,j ); C(i,j+1UL) += A(i,i) * B(i,j+1UL); } if( jpos < jend ) { C(i,jpos) += A(i,i) * B(i,jpos); } } } /*! \endcond */ //********************************************************************************************** //**Default addition assignment to dense matrices (diagonal/diagonal)*************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default addition assignment of a diagonal dense matrix-diagonal dense matrix // multiplication (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default addition assignment of a diagonal dense matrix-diagonal // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< IsDiagonal<MT4>, IsDiagonal<MT5> > > selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); for( size_t i=0UL; i<A.rows(); ++i ) { C(i,i) += A(i,i) * B(i,i); } } /*! \endcond */ //********************************************************************************************** //**Default addition assignment to dense matrices (small matrices)****************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default addition assignment of a small dense matrix-dense matrix multiplication // (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the addition assignment of a dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectDefaultAddAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Vectorized default addition assignment to row-major dense matrices (small matrices)********* /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default addition assignment of a small dense matrix-dense matrix // multiplication (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default addition assignment of a dense matrix-dense // matrix multiplication expression to a row-major dense matrix. This kernel is optimized for // small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallAddAssignKernel( DenseMatrix<MT3,false>& C, const MT4& A, const MT5& B ) { constexpr bool remainder( !IsPadded<MT3>::value || !IsPadded<MT5>::value ); const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( LOW || UPP ) || ( M == N ), "Broken invariant detected" ); const size_t jpos( remainder ? ( N & size_t(-SIMDSIZE) ) : N ); BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % SIMDSIZE ) ) == jpos, "Invalid end calculation" ); size_t j( 0UL ); if( IsIntegral<ElementType>::value ) { for( ; !LOW && !UPP && (j+SIMDSIZE*7UL) < jpos; j+=SIMDSIZE*8UL ) { for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i : i+1UL ), j+SIMDSIZE*8UL, K ) ) :( IsStrictlyLower<MT4>::value ? i : i+1UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*8UL, K ) : K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i,j+SIMDSIZE*3UL) ); SIMDType xmm5( (~C).load(i,j+SIMDSIZE*4UL) ); SIMDType xmm6( (~C).load(i,j+SIMDSIZE*5UL) ); SIMDType xmm7( (~C).load(i,j+SIMDSIZE*6UL) ); SIMDType xmm8( (~C).load(i,j+SIMDSIZE*7UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); xmm6 += a1 * B.load(k,j+SIMDSIZE*5UL); xmm7 += a1 * B.load(k,j+SIMDSIZE*6UL); xmm8 += a1 * B.load(k,j+SIMDSIZE*7UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); (~C).store( i, j+SIMDSIZE*4UL, xmm5 ); (~C).store( i, j+SIMDSIZE*5UL, xmm6 ); (~C).store( i, j+SIMDSIZE*6UL, xmm7 ); (~C).store( i, j+SIMDSIZE*7UL, xmm8 ); } } } for( ; !LOW && !UPP && (j+SIMDSIZE*4UL) < jpos; j+=SIMDSIZE*5UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*5UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*5UL, K ) : K ) ); SIMDType xmm1 ( (~C).load(i ,j ) ); SIMDType xmm2 ( (~C).load(i ,j+SIMDSIZE ) ); SIMDType xmm3 ( (~C).load(i ,j+SIMDSIZE*2UL) ); SIMDType xmm4 ( (~C).load(i ,j+SIMDSIZE*3UL) ); SIMDType xmm5 ( (~C).load(i ,j+SIMDSIZE*4UL) ); SIMDType xmm6 ( (~C).load(i+1UL,j ) ); SIMDType xmm7 ( (~C).load(i+1UL,j+SIMDSIZE ) ); SIMDType xmm8 ( (~C).load(i+1UL,j+SIMDSIZE*2UL) ); SIMDType xmm9 ( (~C).load(i+1UL,j+SIMDSIZE*3UL) ); SIMDType xmm10( (~C).load(i+1UL,j+SIMDSIZE*4UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); const SIMDType b5( B.load(k,j+SIMDSIZE*4UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a1 * b5; xmm6 += a2 * b1; xmm7 += a2 * b2; xmm8 += a2 * b3; xmm9 += a2 * b4; xmm10 += a2 * b5; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i , j+SIMDSIZE*3UL, xmm4 ); (~C).store( i , j+SIMDSIZE*4UL, xmm5 ); (~C).store( i+1UL, j , xmm6 ); (~C).store( i+1UL, j+SIMDSIZE , xmm7 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm8 ); (~C).store( i+1UL, j+SIMDSIZE*3UL, xmm9 ); (~C).store( i+1UL, j+SIMDSIZE*4UL, xmm10 ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*5UL, K ) ):( K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i,j+SIMDSIZE*3UL) ); SIMDType xmm5( (~C).load(i,j+SIMDSIZE*4UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); (~C).store( i, j+SIMDSIZE*4UL, xmm5 ); } } for( ; !LOW && !UPP && (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*4UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*4UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i ,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i ,j+SIMDSIZE*3UL) ); SIMDType xmm5( (~C).load(i+1UL,j ) ); SIMDType xmm6( (~C).load(i+1UL,j+SIMDSIZE ) ); SIMDType xmm7( (~C).load(i+1UL,j+SIMDSIZE*2UL) ); SIMDType xmm8( (~C).load(i+1UL,j+SIMDSIZE*3UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a2 * b1; xmm6 += a2 * b2; xmm7 += a2 * b3; xmm8 += a2 * b4; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i , j+SIMDSIZE*3UL, xmm4 ); (~C).store( i+1UL, j , xmm5 ); (~C).store( i+1UL, j+SIMDSIZE , xmm6 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm7 ); (~C).store( i+1UL, j+SIMDSIZE*3UL, xmm8 ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*4UL, K ) ):( K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i,j+SIMDSIZE*3UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); } } for( ; !LOW && !UPP && (j+SIMDSIZE*2UL) < jpos; j+=SIMDSIZE*3UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*3UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*3UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i ,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i+1UL,j ) ); SIMDType xmm5( (~C).load(i+1UL,j+SIMDSIZE ) ); SIMDType xmm6( (~C).load(i+1UL,j+SIMDSIZE*2UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a2 * b1; xmm5 += a2 * b2; xmm6 += a2 * b3; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i+1UL, j , xmm4 ); (~C).store( i+1UL, j+SIMDSIZE , xmm5 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm6 ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*3UL, K ) ):( K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i,j+SIMDSIZE*2UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); } } for( ; !( LOW && UPP ) && (j+SIMDSIZE) < jpos; j+=SIMDSIZE*2UL ) { const size_t iend( UPP ? min(j+SIMDSIZE*2UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE) ); SIMDType xmm3( (~C).load(i+1UL,j ) ); SIMDType xmm4( (~C).load(i+1UL,j+SIMDSIZE) ); SIMDType xmm5( (~C).load(i+2UL,j ) ); SIMDType xmm6( (~C).load(i+2UL,j+SIMDSIZE) ); SIMDType xmm7( (~C).load(i+3UL,j ) ); SIMDType xmm8( (~C).load(i+3UL,j+SIMDSIZE) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType a4( set( A(i+3UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; xmm7 += a4 * b1; xmm8 += a4 * b2; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE, xmm2 ); (~C).store( i+1UL, j , xmm3 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4 ); (~C).store( i+2UL, j , xmm5 ); (~C).store( i+2UL, j+SIMDSIZE, xmm6 ); (~C).store( i+3UL, j , xmm7 ); (~C).store( i+3UL, j+SIMDSIZE, xmm8 ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE) ); SIMDType xmm3( (~C).load(i+1UL,j ) ); SIMDType xmm4( (~C).load(i+1UL,j+SIMDSIZE) ); SIMDType xmm5( (~C).load(i+2UL,j ) ); SIMDType xmm6( (~C).load(i+2UL,j+SIMDSIZE) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE, xmm2 ); (~C).store( i+1UL, j , xmm3 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4 ); (~C).store( i+2UL, j , xmm5 ); (~C).store( i+2UL, j+SIMDSIZE, xmm6 ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE) ); SIMDType xmm3( (~C).load(i+1UL,j ) ); SIMDType xmm4( (~C).load(i+1UL,j+SIMDSIZE) ); SIMDType xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i ,k ) ) ); const SIMDType a2( set( A(i+1UL,k ) ) ); const SIMDType a3( set( A(i ,k+1UL) ) ); const SIMDType a4( set( A(i+1UL,k+1UL) ) ); const SIMDType b1( B.load(k ,j ) ); const SIMDType b2( B.load(k ,j+SIMDSIZE) ); const SIMDType b3( B.load(k+1UL,j ) ); const SIMDType b4( B.load(k+1UL,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b3; xmm6 += a3 * b4; xmm7 += a4 * b3; xmm8 += a4 * b4; } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; } (~C).store( i , j , xmm1+xmm5 ); (~C).store( i , j+SIMDSIZE, xmm2+xmm6 ); (~C).store( i+1UL, j , xmm3+xmm7 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4+xmm8 ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*2UL, K ) ):( K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE) ); SIMDType xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i,k ) ) ); const SIMDType a2( set( A(i,k+1UL) ) ); xmm1 += a1 * B.load(k ,j ); xmm2 += a1 * B.load(k ,j+SIMDSIZE); xmm3 += a2 * B.load(k+1UL,j ); xmm4 += a2 * B.load(k+1UL,j+SIMDSIZE); } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE); } (~C).store( i, j , xmm1+xmm3 ); (~C).store( i, j+SIMDSIZE, xmm2+xmm4 ); } } for( ; j<jpos; j+=SIMDSIZE ) { const size_t iend( LOW && UPP ? min(j+SIMDSIZE,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) :( K ) ); SIMDType xmm1( (~C).load(i ,j) ); SIMDType xmm2( (~C).load(i+1UL,j) ); SIMDType xmm3( (~C).load(i+2UL,j) ); SIMDType xmm4( (~C).load(i+3UL,j) ); SIMDType xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i+3UL,k ) ) * b1; xmm5 += set( A(i ,k+1UL) ) * b2; xmm6 += set( A(i+1UL,k+1UL) ) * b2; xmm7 += set( A(i+2UL,k+1UL) ) * b2; xmm8 += set( A(i+3UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; xmm4 += set( A(i+3UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm5 ); (~C).store( i+1UL, j, xmm2+xmm6 ); (~C).store( i+2UL, j, xmm3+xmm7 ); (~C).store( i+3UL, j, xmm4+xmm8 ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) :( K ) ); SIMDType xmm1( (~C).load(i ,j) ); SIMDType xmm2( (~C).load(i+1UL,j) ); SIMDType xmm3( (~C).load(i+2UL,j) ); SIMDType xmm4, xmm5, xmm6; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i ,k+1UL) ) * b2; xmm5 += set( A(i+1UL,k+1UL) ) * b2; xmm6 += set( A(i+2UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm4 ); (~C).store( i+1UL, j, xmm2+xmm5 ); (~C).store( i+2UL, j, xmm3+xmm6 ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); SIMDType xmm1( (~C).load(i ,j) ); SIMDType xmm2( (~C).load(i+1UL,j) ); SIMDType xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i ,k+1UL) ) * b2; xmm4 += set( A(i+1UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm3 ); (~C).store( i+1UL, j, xmm2+xmm4 ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); SIMDType xmm1( (~C).load(i,j) ); SIMDType xmm2; size_t k( kbegin ); for( ; (k+2UL) <= K; k+=2UL ) { xmm1 += set( A(i,k ) ) * B.load(k ,j); xmm2 += set( A(i,k+1UL) ) * B.load(k+1UL,j); } for( ; k<K; ++k ) { xmm1 += set( A(i,k) ) * B.load(k,j); } (~C).store( i, j, xmm1+xmm2 ); } } for( ; remainder && j<N; ++j ) { const size_t iend( UPP ? j+1UL : M ); size_t i( LOW ? j : 0UL ); for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); ElementType value1( (~C)(i ,j) ); ElementType value2( (~C)(i+1UL,j) );; for( size_t k=kbegin; k<kend; ++k ) { value1 += A(i ,k) * B(k,j); value2 += A(i+1UL,k) * B(k,j); } (~C)(i ,j) = value1; (~C)(i+1UL,j) = value2; } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); ElementType value( (~C)(i,j) ); for( size_t k=kbegin; k<K; ++k ) { value += A(i,k) * B(k,j); } (~C)(i,j) = value; } } } /*! \endcond */ //********************************************************************************************** //**Vectorized default addition assignment to column-major dense matrices (small matrices)****** /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default addition assignment of a small dense matrix-dense matrix // multiplication (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default addition assignment of a small dense // matrix-dense matrix multiplication expression to a column-major dense matrix. This // kernel is optimized for small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallAddAssignKernel( DenseMatrix<MT3,true>& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT4 ); BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT5 ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT4> ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT5> ); const ForwardFunctor fwd; if( !IsResizable<MT4>::value && IsResizable<MT5>::value ) { const OppositeType_<MT4> tmp( serial( A ) ); addAssign( ~C, fwd( tmp * B ) ); } else if( IsResizable<MT4>::value && !IsResizable<MT5>::value ) { const OppositeType_<MT5> tmp( serial( B ) ); addAssign( ~C, fwd( A * tmp ) ); } else if( A.rows() * A.columns() <= B.rows() * B.columns() ) { const OppositeType_<MT4> tmp( serial( A ) ); addAssign( ~C, fwd( tmp * B ) ); } else { const OppositeType_<MT5> tmp( serial( B ) ); addAssign( ~C, fwd( A * tmp ) ); } } /*! \endcond */ //********************************************************************************************** //**Default addition assignment to dense matrices (large matrices)****************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default addition assignment of a large dense matrix-dense matrix multiplication // (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the addition assignment of a dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectDefaultAddAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Vectorized default addition assignment to dense matrices (large matrices)******************* /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default addition assignment of a large dense matrix-dense matrix // multiplication (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default addition assignment of a dense matrix- // dense matrix multiplication expression to a dense matrix. This kernel is optimized for // large matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { if( LOW ) lmmm( C, A, B, ElementType(1), ElementType(1) ); else if( UPP ) ummm( C, A, B, ElementType(1), ElementType(1) ); else mmm( C, A, B, ElementType(1), ElementType(1) ); } /*! \endcond */ //********************************************************************************************** //**BLAS-based addition assignment to dense matrices (default)********************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default addition assignment of a dense matrix-dense matrix multiplication // (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the addition assignment of a large // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseBlasKernel<MT3,MT4,MT5> > selectBlasAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectLargeAddAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**BLAS-based addition assignment to dense matrices******************************************** #if BLAZE_BLAS_MODE && BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION /*! \cond BLAZE_INTERNAL */ /*!\brief BLAS-based addition assignment of a dense matrix-dense matrix multiplication // (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function performs the dense matrix-dense matrix multiplication based on the according // BLAS functionality. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseBlasKernel<MT3,MT4,MT5> > selectBlasAddAssignKernel( MT3& C, const MT4& A, const MT5& B ) { using ET = ElementType_<MT3>; if( IsTriangular<MT4>::value ) { ResultType_<MT3> tmp( serial( B ) ); trmm( tmp, A, CblasLeft, ( IsLower<MT4>::value )?( CblasLower ):( CblasUpper ), ET(1) ); addAssign( C, tmp ); } else if( IsTriangular<MT5>::value ) { ResultType_<MT3> tmp( serial( A ) ); trmm( tmp, B, CblasRight, ( IsLower<MT5>::value )?( CblasLower ):( CblasUpper ), ET(1) ); addAssign( C, tmp ); } else { gemm( C, A, B, ET(1), ET(1) ); } } /*! \endcond */ #endif //********************************************************************************************** //**Restructuring addition assignment to column-major matrices********************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Restructuring addition assignment of a dense matrix-dense matrix multiplication to a // column-major matrix (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side multiplication expression to be added. // \return void // // This function implements the symmetry-based restructuring addition assignment of a dense // matrix-dense matrix multiplication expression to a column-major matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler // in case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > addAssign( Matrix<MT,true>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) ); else if( IsSymmetric<MT1>::value ) addAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) ); else addAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) ); } /*! \endcond */ //********************************************************************************************** //**Addition assignment to sparse matrices****************************************************** // No special implementation for the addition assignment to sparse matrices. //********************************************************************************************** //**Subtraction assignment to dense matrices**************************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Subtraction assignment of a dense matrix-dense matrix multiplication to a // dense matrix (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side multiplication expression to be subtracted. // \return void // // This function implements the performance optimized subtraction assignment of a dense matrix- // dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> > subAssign( DenseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL || rhs.lhs_.columns() == 0UL ) { return; } LT A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand RT B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" ); DMatDMatMultExpr::selectSubAssignKernel( ~lhs, A, B ); } /*! \endcond */ //********************************************************************************************** //**Subtraction assignment to dense matrices (kernel selection)********************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Selection of the kernel for a subtraction assignment of a dense matrix-dense matrix // multiplication to a dense matrix (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline void selectSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { if( ( IsDiagonal<MT5>::value ) || ( !BLAZE_DEBUG_MODE && B.columns() <= SIMDSIZE*10UL ) || ( C.rows() * C.columns() < DMATDMATMULT_THRESHOLD ) ) selectSmallSubAssignKernel( C, A, B ); else selectBlasSubAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Default subtraction assignment to dense matrices (general/general)************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default subtraction assignment of a general dense matrix-general dense matrix // multiplication (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default subtraction assignment of a general dense matrix- // general dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< Not< IsDiagonal<MT4> >, Not< IsDiagonal<MT5> > > > selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( LOW || UPP ) || ( M == N ), "Broken invariant detected" ); for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( K ) ); BLAZE_INTERNAL_ASSERT( kbegin <= kend, "Invalid loop indices detected" ); for( size_t k=kbegin; k<kend; ++k ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( ( IsStrictlyUpper<MT5>::value ) ?( UPP ? max(i,k+1UL) : k+1UL ) :( UPP ? max(i,k) : k ) ) :( UPP ? i : 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( ( IsStrictlyLower<MT5>::value ) ?( LOW ? min(i+1UL,k) : k ) :( LOW ? min(i,k)+1UL : k+1UL ) ) :( LOW ? i+1UL : N ) ); if( ( LOW || UPP ) && ( jbegin >= jend ) ) continue; BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) -= A(i,k) * B(k,j ); C(i,j+1UL) -= A(i,k) * B(k,j+1UL); } if( jpos < jend ) { C(i,jpos) -= A(i,k) * B(k,jpos); } } } } /*! \endcond */ //********************************************************************************************** //**Default subtraction assignment to dense matrices (general/diagonal)************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Default subtraction assignment of a general dense matrix-diagonal dense matrix // multiplication (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default subtraction assignment of a general dense matrix- // diagonal dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< Not< IsDiagonal<MT4> >, IsDiagonal<MT5> > > selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) -= A(i,j ) * B(j ,j ); C(i,j+1UL) -= A(i,j+1UL) * B(j+1UL,j+1UL); } if( jpos < jend ) { C(i,jpos) -= A(i,jpos) * B(jpos,jpos); } } } /*! \endcond */ //********************************************************************************************** //**Default subtraction assignment to dense matrices (diagonal/general)************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Default subtraction assignment of a diagonal dense matrix-general dense matrix // multiplication (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default subtraction assignment of a diagonal dense matrix- // general dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< IsDiagonal<MT4>, Not< IsDiagonal<MT5> > > > selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( IsStrictlyUpper<MT5>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( IsStrictlyLower<MT5>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) -= A(i,i) * B(i,j ); C(i,j+1UL) -= A(i,i) * B(i,j+1UL); } if( jpos < jend ) { C(i,jpos) -= A(i,i) * B(i,jpos); } } } /*! \endcond */ //********************************************************************************************** //**Default subtraction assignment to dense matrices (diagonal/diagonal)************************ /*! \cond BLAZE_INTERNAL */ /*!\brief Default subtraction assignment of a diagonal dense matrix-diagonal dense matrix // multiplication (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the default subtraction assignment of a diagonal dense matrix- // diagonal dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< And< IsDiagonal<MT4>, IsDiagonal<MT5> > > selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); for( size_t i=0UL; i<A.rows(); ++i ) { C(i,i) -= A(i,i) * B(i,i); } } /*! \endcond */ //********************************************************************************************** //**Default subtraction assignment to dense matrices (small matrices)*************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default subtraction assignment of a small dense matrix-dense matrix multiplication // (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the subtraction assignment of a dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectDefaultSubAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Vectorized default subtraction assignment to row-major dense matrices (small matrices)****** /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default subtraction assignment of a small dense matrix-dense matrix // multiplication (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default subtraction assignment of a dense matrix- // dense matrix multiplication expression to a row-major dense matrix. This kernel is optimized // for small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallSubAssignKernel( DenseMatrix<MT3,false>& C, const MT4& A, const MT5& B ) { constexpr bool remainder( !IsPadded<MT3>::value || !IsPadded<MT5>::value ); const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( LOW || UPP ) || ( M == N ), "Broken invariant detected" ); const size_t jpos( remainder ? ( N & size_t(-SIMDSIZE) ) : N ); BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % SIMDSIZE ) ) == jpos, "Invalid end calculation" ); size_t j( 0UL ); if( IsIntegral<ElementType>::value ) { for( ; !LOW && !UPP && (j+SIMDSIZE*7UL) < jpos; j+=SIMDSIZE*8UL ) { for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i : i+1UL ), j+SIMDSIZE*8UL, K ) ) :( IsStrictlyLower<MT4>::value ? i : i+1UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*8UL, K ) : K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i,j+SIMDSIZE*3UL) ); SIMDType xmm5( (~C).load(i,j+SIMDSIZE*4UL) ); SIMDType xmm6( (~C).load(i,j+SIMDSIZE*5UL) ); SIMDType xmm7( (~C).load(i,j+SIMDSIZE*6UL) ); SIMDType xmm8( (~C).load(i,j+SIMDSIZE*7UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 -= a1 * B.load(k,j ); xmm2 -= a1 * B.load(k,j+SIMDSIZE ); xmm3 -= a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 -= a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 -= a1 * B.load(k,j+SIMDSIZE*4UL); xmm6 -= a1 * B.load(k,j+SIMDSIZE*5UL); xmm7 -= a1 * B.load(k,j+SIMDSIZE*6UL); xmm8 -= a1 * B.load(k,j+SIMDSIZE*7UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); (~C).store( i, j+SIMDSIZE*4UL, xmm5 ); (~C).store( i, j+SIMDSIZE*5UL, xmm6 ); (~C).store( i, j+SIMDSIZE*6UL, xmm7 ); (~C).store( i, j+SIMDSIZE*7UL, xmm8 ); } } } for( ; !LOW && !UPP && (j+SIMDSIZE*4UL) < jpos; j+=SIMDSIZE*5UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*5UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*5UL, K ) : K ) ); SIMDType xmm1 ( (~C).load(i ,j ) ); SIMDType xmm2 ( (~C).load(i ,j+SIMDSIZE ) ); SIMDType xmm3 ( (~C).load(i ,j+SIMDSIZE*2UL) ); SIMDType xmm4 ( (~C).load(i ,j+SIMDSIZE*3UL) ); SIMDType xmm5 ( (~C).load(i ,j+SIMDSIZE*4UL) ); SIMDType xmm6 ( (~C).load(i+1UL,j ) ); SIMDType xmm7 ( (~C).load(i+1UL,j+SIMDSIZE ) ); SIMDType xmm8 ( (~C).load(i+1UL,j+SIMDSIZE*2UL) ); SIMDType xmm9 ( (~C).load(i+1UL,j+SIMDSIZE*3UL) ); SIMDType xmm10( (~C).load(i+1UL,j+SIMDSIZE*4UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); const SIMDType b5( B.load(k,j+SIMDSIZE*4UL) ); xmm1 -= a1 * b1; xmm2 -= a1 * b2; xmm3 -= a1 * b3; xmm4 -= a1 * b4; xmm5 -= a1 * b5; xmm6 -= a2 * b1; xmm7 -= a2 * b2; xmm8 -= a2 * b3; xmm9 -= a2 * b4; xmm10 -= a2 * b5; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i , j+SIMDSIZE*3UL, xmm4 ); (~C).store( i , j+SIMDSIZE*4UL, xmm5 ); (~C).store( i+1UL, j , xmm6 ); (~C).store( i+1UL, j+SIMDSIZE , xmm7 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm8 ); (~C).store( i+1UL, j+SIMDSIZE*3UL, xmm9 ); (~C).store( i+1UL, j+SIMDSIZE*4UL, xmm10 ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*5UL, K ) ):( K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i,j+SIMDSIZE*3UL) ); SIMDType xmm5( (~C).load(i,j+SIMDSIZE*4UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 -= a1 * B.load(k,j ); xmm2 -= a1 * B.load(k,j+SIMDSIZE ); xmm3 -= a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 -= a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 -= a1 * B.load(k,j+SIMDSIZE*4UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); (~C).store( i, j+SIMDSIZE*4UL, xmm5 ); } } for( ; !LOW && !UPP && (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*4UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*4UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i ,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i ,j+SIMDSIZE*3UL) ); SIMDType xmm5( (~C).load(i+1UL,j ) ); SIMDType xmm6( (~C).load(i+1UL,j+SIMDSIZE ) ); SIMDType xmm7( (~C).load(i+1UL,j+SIMDSIZE*2UL) ); SIMDType xmm8( (~C).load(i+1UL,j+SIMDSIZE*3UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); xmm1 -= a1 * b1; xmm2 -= a1 * b2; xmm3 -= a1 * b3; xmm4 -= a1 * b4; xmm5 -= a2 * b1; xmm6 -= a2 * b2; xmm7 -= a2 * b3; xmm8 -= a2 * b4; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i , j+SIMDSIZE*3UL, xmm4 ); (~C).store( i+1UL, j , xmm5 ); (~C).store( i+1UL, j+SIMDSIZE , xmm6 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm7 ); (~C).store( i+1UL, j+SIMDSIZE*3UL, xmm8 ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*4UL, K ) ):( K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i,j+SIMDSIZE*3UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 -= a1 * B.load(k,j ); xmm2 -= a1 * B.load(k,j+SIMDSIZE ); xmm3 -= a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 -= a1 * B.load(k,j+SIMDSIZE*3UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 ); } } for( ; !LOW && !UPP && (j+SIMDSIZE*2UL) < jpos; j+=SIMDSIZE*3UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*3UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*3UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i ,j+SIMDSIZE*2UL) ); SIMDType xmm4( (~C).load(i+1UL,j ) ); SIMDType xmm5( (~C).load(i+1UL,j+SIMDSIZE ) ); SIMDType xmm6( (~C).load(i+1UL,j+SIMDSIZE*2UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); xmm1 -= a1 * b1; xmm2 -= a1 * b2; xmm3 -= a1 * b3; xmm4 -= a2 * b1; xmm5 -= a2 * b2; xmm6 -= a2 * b3; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE , xmm2 ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 ); (~C).store( i+1UL, j , xmm4 ); (~C).store( i+1UL, j+SIMDSIZE , xmm5 ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm6 ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*3UL, K ) ):( K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE ) ); SIMDType xmm3( (~C).load(i,j+SIMDSIZE*2UL) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 -= a1 * B.load(k,j ); xmm2 -= a1 * B.load(k,j+SIMDSIZE ); xmm3 -= a1 * B.load(k,j+SIMDSIZE*2UL); } (~C).store( i, j , xmm1 ); (~C).store( i, j+SIMDSIZE , xmm2 ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 ); } } for( ; !( LOW && UPP ) && (j+SIMDSIZE) < jpos; j+=SIMDSIZE*2UL ) { const size_t iend( UPP ? min(j+SIMDSIZE*2UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE) ); SIMDType xmm3( (~C).load(i+1UL,j ) ); SIMDType xmm4( (~C).load(i+1UL,j+SIMDSIZE) ); SIMDType xmm5( (~C).load(i+2UL,j ) ); SIMDType xmm6( (~C).load(i+2UL,j+SIMDSIZE) ); SIMDType xmm7( (~C).load(i+3UL,j ) ); SIMDType xmm8( (~C).load(i+3UL,j+SIMDSIZE) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType a4( set( A(i+3UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 -= a1 * b1; xmm2 -= a1 * b2; xmm3 -= a2 * b1; xmm4 -= a2 * b2; xmm5 -= a3 * b1; xmm6 -= a3 * b2; xmm7 -= a4 * b1; xmm8 -= a4 * b2; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE, xmm2 ); (~C).store( i+1UL, j , xmm3 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4 ); (~C).store( i+2UL, j , xmm5 ); (~C).store( i+2UL, j+SIMDSIZE, xmm6 ); (~C).store( i+3UL, j , xmm7 ); (~C).store( i+3UL, j+SIMDSIZE, xmm8 ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE) ); SIMDType xmm3( (~C).load(i+1UL,j ) ); SIMDType xmm4( (~C).load(i+1UL,j+SIMDSIZE) ); SIMDType xmm5( (~C).load(i+2UL,j ) ); SIMDType xmm6( (~C).load(i+2UL,j+SIMDSIZE) ); for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 -= a1 * b1; xmm2 -= a1 * b2; xmm3 -= a2 * b1; xmm4 -= a2 * b2; xmm5 -= a3 * b1; xmm6 -= a3 * b2; } (~C).store( i , j , xmm1 ); (~C).store( i , j+SIMDSIZE, xmm2 ); (~C).store( i+1UL, j , xmm3 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4 ); (~C).store( i+2UL, j , xmm5 ); (~C).store( i+2UL, j+SIMDSIZE, xmm6 ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1( (~C).load(i ,j ) ); SIMDType xmm2( (~C).load(i ,j+SIMDSIZE) ); SIMDType xmm3( (~C).load(i+1UL,j ) ); SIMDType xmm4( (~C).load(i+1UL,j+SIMDSIZE) ); SIMDType xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i ,k ) ) ); const SIMDType a2( set( A(i+1UL,k ) ) ); const SIMDType a3( set( A(i ,k+1UL) ) ); const SIMDType a4( set( A(i+1UL,k+1UL) ) ); const SIMDType b1( B.load(k ,j ) ); const SIMDType b2( B.load(k ,j+SIMDSIZE) ); const SIMDType b3( B.load(k+1UL,j ) ); const SIMDType b4( B.load(k+1UL,j+SIMDSIZE) ); xmm1 -= a1 * b1; xmm2 -= a1 * b2; xmm3 -= a2 * b1; xmm4 -= a2 * b2; xmm5 -= a3 * b3; xmm6 -= a3 * b4; xmm7 -= a4 * b3; xmm8 -= a4 * b4; } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 -= a1 * b1; xmm2 -= a1 * b2; xmm3 -= a2 * b1; xmm4 -= a2 * b2; } (~C).store( i , j , xmm1+xmm5 ); (~C).store( i , j+SIMDSIZE, xmm2+xmm6 ); (~C).store( i+1UL, j , xmm3+xmm7 ); (~C).store( i+1UL, j+SIMDSIZE, xmm4+xmm8 ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*2UL, K ) ):( K ) ); SIMDType xmm1( (~C).load(i,j ) ); SIMDType xmm2( (~C).load(i,j+SIMDSIZE) ); SIMDType xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i,k ) ) ); const SIMDType a2( set( A(i,k+1UL) ) ); xmm1 -= a1 * B.load(k ,j ); xmm2 -= a1 * B.load(k ,j+SIMDSIZE); xmm3 -= a2 * B.load(k+1UL,j ); xmm4 -= a2 * B.load(k+1UL,j+SIMDSIZE); } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 -= a1 * B.load(k,j ); xmm2 -= a1 * B.load(k,j+SIMDSIZE); } (~C).store( i, j , xmm1+xmm3 ); (~C).store( i, j+SIMDSIZE, xmm2+xmm4 ); } } for( ; j<jpos; j+=SIMDSIZE ) { const size_t iend( LOW && UPP ? min(j+SIMDSIZE,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) :( K ) ); SIMDType xmm1( (~C).load(i ,j) ); SIMDType xmm2( (~C).load(i+1UL,j) ); SIMDType xmm3( (~C).load(i+2UL,j) ); SIMDType xmm4( (~C).load(i+3UL,j) ); SIMDType xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 -= set( A(i ,k ) ) * b1; xmm2 -= set( A(i+1UL,k ) ) * b1; xmm3 -= set( A(i+2UL,k ) ) * b1; xmm4 -= set( A(i+3UL,k ) ) * b1; xmm5 -= set( A(i ,k+1UL) ) * b2; xmm6 -= set( A(i+1UL,k+1UL) ) * b2; xmm7 -= set( A(i+2UL,k+1UL) ) * b2; xmm8 -= set( A(i+3UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 -= set( A(i ,k) ) * b1; xmm2 -= set( A(i+1UL,k) ) * b1; xmm3 -= set( A(i+2UL,k) ) * b1; xmm4 -= set( A(i+3UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm5 ); (~C).store( i+1UL, j, xmm2+xmm6 ); (~C).store( i+2UL, j, xmm3+xmm7 ); (~C).store( i+3UL, j, xmm4+xmm8 ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) :( K ) ); SIMDType xmm1( (~C).load(i ,j) ); SIMDType xmm2( (~C).load(i+1UL,j) ); SIMDType xmm3( (~C).load(i+2UL,j) ); SIMDType xmm4, xmm5, xmm6; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 -= set( A(i ,k ) ) * b1; xmm2 -= set( A(i+1UL,k ) ) * b1; xmm3 -= set( A(i+2UL,k ) ) * b1; xmm4 -= set( A(i ,k+1UL) ) * b2; xmm5 -= set( A(i+1UL,k+1UL) ) * b2; xmm6 -= set( A(i+2UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 -= set( A(i ,k) ) * b1; xmm2 -= set( A(i+1UL,k) ) * b1; xmm3 -= set( A(i+2UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm4 ); (~C).store( i+1UL, j, xmm2+xmm5 ); (~C).store( i+2UL, j, xmm3+xmm6 ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); SIMDType xmm1( (~C).load(i ,j) ); SIMDType xmm2( (~C).load(i+1UL,j) ); SIMDType xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 -= set( A(i ,k ) ) * b1; xmm2 -= set( A(i+1UL,k ) ) * b1; xmm3 -= set( A(i ,k+1UL) ) * b2; xmm4 -= set( A(i+1UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 -= set( A(i ,k) ) * b1; xmm2 -= set( A(i+1UL,k) ) * b1; } (~C).store( i , j, xmm1+xmm3 ); (~C).store( i+1UL, j, xmm2+xmm4 ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); SIMDType xmm1( (~C).load(i,j) ); SIMDType xmm2; size_t k( kbegin ); for( ; (k+2UL) <= K; k+=2UL ) { xmm1 -= set( A(i,k ) ) * B.load(k ,j); xmm2 -= set( A(i,k+1UL) ) * B.load(k+1UL,j); } for( ; k<K; ++k ) { xmm1 -= set( A(i,k) ) * B.load(k,j); } (~C).store( i, j, xmm1+xmm2 ); } } for( ; remainder && j<N; ++j ) { const size_t iend( UPP ? j+1UL : M ); size_t i( LOW ? j : 0UL ); for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); ElementType value1( (~C)(i ,j) ); ElementType value2( (~C)(i+1UL,j) ); for( size_t k=kbegin; k<kend; ++k ) { value1 -= A(i ,k) * B(k,j); value2 -= A(i+1UL,k) * B(k,j); } (~C)(i ,j) = value1; (~C)(i+1UL,j) = value2; } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); ElementType value( (~C)(i,j) ); for( size_t k=kbegin; k<K; ++k ) { value -= A(i,k) * B(k,j); } (~C)(i,j) = value; } } } /*! \endcond */ //********************************************************************************************** //**Vectorized default subtraction assignment to column-major dense matrices (small matrices)*** /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default subtraction assignment of a small dense matrix-dense matrix // multiplication (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default subtraction assignment of a dense matrix- // dense matrix multiplication expression to a column-major dense matrix. This kernel is // optimized for small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectSmallSubAssignKernel( DenseMatrix<MT3,true>& C, const MT4& A, const MT5& B ) { BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT4 ); BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT5 ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT4> ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT5> ); const ForwardFunctor fwd; if( !IsResizable<MT4>::value && IsResizable<MT5>::value ) { const OppositeType_<MT4> tmp( serial( A ) ); subAssign( ~C, fwd( tmp * B ) ); } else if( IsResizable<MT4>::value && !IsResizable<MT5>::value ) { const OppositeType_<MT5> tmp( serial( B ) ); subAssign( ~C, fwd( A * tmp ) ); } else if( A.rows() * A.columns() <= B.rows() * B.columns() ) { const OppositeType_<MT4> tmp( serial( A ) ); subAssign( ~C, fwd( tmp * B ) ); } else { const OppositeType_<MT5> tmp( serial( B ) ); subAssign( ~C, fwd( A * tmp ) ); } } /*! \endcond */ //********************************************************************************************** //**Default subtraction assignment to dense matrices (large matrices)*************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Default subtraction assignment of a large dense matrix-dense matrix multiplication // (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the subtraction assignment of a dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectDefaultSubAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**Vectorized default subtraction assignment to dense matrices (large matrices)**************** /*! \cond BLAZE_INTERNAL */ /*!\brief Vectorized default subtraction assignment of a large dense matrix-dense matrix // multiplication (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function implements the vectorized default subtraction assignment of a dense matrix- // dense matrix multiplication expression to a dense matrix. This kernel is optimized for // large matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5> > selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { if( LOW ) lmmm( C, A, B, ElementType(-1), ElementType(1) ); else if( UPP ) ummm( C, A, B, ElementType(-1), ElementType(1) ); else mmm( C, A, B, ElementType(-1), ElementType(1) ); } /*! \endcond */ //********************************************************************************************** //**BLAS-based subtraction assignment to dense matrices (default)******************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Default subtraction assignment of a dense matrix-dense matrix multiplication // (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function relays to the default implementation of the subtraction assignment of a large // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline DisableIf_< UseBlasKernel<MT3,MT4,MT5> > selectBlasSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { selectLargeSubAssignKernel( C, A, B ); } /*! \endcond */ //********************************************************************************************** //**BLAS-based subraction assignment to dense matrices****************************************** #if BLAZE_BLAS_MODE && BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION /*! \cond BLAZE_INTERNAL */ /*!\brief BLAS-based subraction assignment of a dense matrix-dense matrix multiplication // (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \return void // // This function performs the dense matrix-dense matrix multiplication based on the according // BLAS functionality. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 > // Type of the right-hand side matrix operand static inline EnableIf_< UseBlasKernel<MT3,MT4,MT5> > selectBlasSubAssignKernel( MT3& C, const MT4& A, const MT5& B ) { using ET = ElementType_<MT3>; if( IsTriangular<MT4>::value ) { ResultType_<MT3> tmp( serial( B ) ); trmm( tmp, A, CblasLeft, ( IsLower<MT4>::value )?( CblasLower ):( CblasUpper ), ET(1) ); subAssign( C, tmp ); } else if( IsTriangular<MT5>::value ) { ResultType_<MT3> tmp( serial( A ) ); trmm( tmp, B, CblasRight, ( IsLower<MT5>::value )?( CblasLower ):( CblasUpper ), ET(1) ); subAssign( C, tmp ); } else { gemm( C, A, B, ET(-1), ET(1) ); } } /*! \endcond */ #endif //********************************************************************************************** //**Restructuring subtraction assignment to column-major matrices******************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Restructuring subtraction assignment of a dense matrix-dense matrix multiplication // to a column-major matrix (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side multiplication expression to be subtracted. // \return void // // This function implements the symmetry-based restructuring subtraction assignment of a dense // matrix-dense matrix multiplication expression to a column-major matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler in // case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > subAssign( Matrix<MT,true>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) ); else if( IsSymmetric<MT1>::value ) subAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) ); else subAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) ); } /*! \endcond */ //********************************************************************************************** //**Subtraction assignment to sparse matrices*************************************************** // No special implementation for the subtraction assignment to sparse matrices. //********************************************************************************************** //**Schur product assignment to dense matrices************************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Schur product assignment of a dense matrix-dense matrix multiplication to a dense // matrix (\f$ C\circ=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side multiplication expression for the Schur product. // \return void // // This function implements the performance optimized Schur product assignment of a dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline void schurAssign( DenseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ResultType tmp( serial( rhs ) ); schurAssign( ~lhs, tmp ); } /*! \endcond */ //********************************************************************************************** //**Schur product assignment to sparse matrices************************************************* // No special implementation for the Schur product assignment to sparse matrices. //********************************************************************************************** //**Multiplication assignment to dense matrices************************************************* // No special implementation for the multiplication assignment to dense matrices. //********************************************************************************************** //**Multiplication assignment to sparse matrices************************************************ // No special implementation for the multiplication assignment to sparse matrices. //********************************************************************************************** //**SMP assignment to dense matrices************************************************************ /*! \cond BLAZE_INTERNAL */ /*!\brief SMP assignment of a dense matrix-dense matrix multiplication to a dense matrix // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side multiplication expression to be assigned. // \return void // // This function implements the performance optimized SMP assignment of a dense matrix-dense // matrix multiplication expression to a dense matrix. Due to the explicit application of the // SFINAE principle this function can only be selected by the compiler in case either of the // two matrix operands requires an intermediate evaluation and no symmetry can be exploited. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> > smpAssign( DenseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL ) { return; } else if( rhs.lhs_.columns() == 0UL ) { reset( ~lhs ); return; } LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand RT B( rhs.rhs_ ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" ); smpAssign( ~lhs, A * B ); } /*! \endcond */ //********************************************************************************************** //**SMP assignment to sparse matrices*********************************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief SMP assignment of a dense matrix-dense matrix multiplication to a sparse matrix // (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side sparse matrix. // \param rhs The right-hand side multiplication expression to be assigned. // \return void // // This function implements the performance optimized SMP assignment of a dense matrix-dense // matrix multiplication expression to a sparse matrix. Due to the explicit application of the // SFINAE principle this function can only be selected by the compiler in case either of the // two matrix operands requires an intermediate evaluation and no symmetry can be exploited. */ template< typename MT // Type of the target sparse matrix , bool SO > // Storage order of the target sparse matrix friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> > smpAssign( SparseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; using TmpType = IfTrue_< SO, OppositeType, ResultType >; BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( OppositeType ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType ); BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER( MT, TmpType ); BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( TmpType ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; const TmpType tmp( rhs ); smpAssign( ~lhs, fwd( tmp ) ); } /*! \endcond */ //********************************************************************************************** //**Restructuring SMP assignment to column-major matrices*************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Restructuring SMP assignment of a dense matrix-dense matrix multiplication to a // column-major matrix (\f$ C=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side multiplication expression to be assigned. // \return void // // This function implements the symmetry-based restructuring SMP assignment of a dense matrix- // dense matrix multiplication expression to a column-major matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler in // case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > smpAssign( Matrix<MT,true>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) ); else if( IsSymmetric<MT1>::value ) smpAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) ); else smpAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) ); } /*! \endcond */ //********************************************************************************************** //**SMP addition assignment to dense matrices*************************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief SMP addition assignment of a dense matrix-dense matrix multiplication to a dense // matrix (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side multiplication expression to be added. // \return void // // This function implements the performance optimized SMP addition assignment of a dense // matrix-dense matrix multiplication expression to a dense matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler // in case either of the two matrix operands requires an intermediate evaluation and no // symmetry can be exploited. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> > smpAddAssign( DenseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL || rhs.lhs_.columns() == 0UL ) { return; } LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand RT B( rhs.rhs_ ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" ); smpAddAssign( ~lhs, A * B ); } /*! \endcond */ //********************************************************************************************** //**Restructuring SMP addition assignment to column-major matrices****************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Restructuring SMP addition assignment of a dense matrix-dense matrix multiplication // to a column-major matrix (\f$ C+=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side multiplication expression to be added. // \return void // // This function implements the symmetry-based restructuring SMP addition assignment of a dense // matrix-dense matrix multiplication expression to a column-major matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler in // case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > smpAddAssign( Matrix<MT,true>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) ); else if( IsSymmetric<MT1>::value ) smpAddAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) ); else smpAddAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) ); } /*! \endcond */ //********************************************************************************************** //**SMP addition assignment to sparse matrices************************************************** // No special implementation for the SMP addition assignment to sparse matrices. //********************************************************************************************** //**SMP subtraction assignment to dense matrices************************************************ /*! \cond BLAZE_INTERNAL */ /*!\brief SMP subtraction assignment of a dense matrix-dense matrix multiplication to a // dense matrix (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side multiplication expression to be subtracted. // \return void // // This function implements the performance optimized SMP subtraction assignment of a dense // matrix-dense matrix multiplication expression to a dense matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler // in case either of the two matrix operands requires an intermediate evaluation and no // symmetry can be exploited. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> > smpSubAssign( DenseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL || rhs.lhs_.columns() == 0UL ) { return; } LT A( rhs.lhs_ ); // Evaluation of the left-hand side dense matrix operand RT B( rhs.rhs_ ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" ); smpSubAssign( ~lhs, A * B ); } /*! \endcond */ //********************************************************************************************** //**Restructuring SMP subtraction assignment to column-major matrices*************************** /*! \cond BLAZE_INTERNAL */ /*!\brief Restructuring SMP subtraction assignment of a dense matrix-dense matrix multiplication // to a column-major matrix (\f$ C-=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side multiplication expression to be subtracted. // \return void // // This function implements the symmetry-based restructuring SMP subtraction assignment of a // dense matrix-dense matrix multiplication expression to a column-major matrix. Due to the // explicit application of the SFINAE principle this function can only be selected by the // compiler in case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > smpSubAssign( Matrix<MT,true>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * trans( rhs.rhs_ ) ) ); else if( IsSymmetric<MT1>::value ) smpSubAssign( ~lhs, fwd( trans( rhs.lhs_ ) * rhs.rhs_ ) ); else smpSubAssign( ~lhs, fwd( rhs.lhs_ * trans( rhs.rhs_ ) ) ); } /*! \endcond */ //********************************************************************************************** //**SMP subtraction assignment to sparse matrices*********************************************** // No special implementation for the SMP subtraction assignment to sparse matrices. //********************************************************************************************** //**SMP Schur product assignment to dense matrices********************************************** /*! \cond BLAZE_INTERNAL */ /*!\brief SMP Schur product assignment of a dense matrix-dense matrix multiplication to a // dense matrix (\f$ C\circ=A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side multiplication expression for the Schur product. // \return void // // This function implements the performance optimized SMP Schur product assignment of a // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline void smpSchurAssign( DenseMatrix<MT,SO>& lhs, const DMatDMatMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ResultType tmp( rhs ); smpSchurAssign( ~lhs, tmp ); } /*! \endcond */ //********************************************************************************************** //**SMP Schur product assignment to sparse matrices********************************************* // No special implementation for the SMP Schur product assignment to sparse matrices. //********************************************************************************************** //**SMP multiplication assignment to dense matrices********************************************* // No special implementation for the SMP multiplication assignment to dense matrices. //********************************************************************************************** //**SMP multiplication assignment to sparse matrices******************************************** // No special implementation for the SMP multiplication assignment to sparse matrices. //********************************************************************************************** //**Compile time checks************************************************************************* /*! \cond BLAZE_INTERNAL */ BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( MT1 ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT1 ); BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( MT2 ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT2 ); BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATMULTEXPR( MT1, MT2 ); /*! \endcond */ //********************************************************************************************** }; //************************************************************************************************* //================================================================================================= // // DMATSCALARMULTEXPR SPECIALIZATION // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Expression object for scaled dense matrix-dense matrix multiplications. // \ingroup dense_matrix_expression // // This specialization of the DMatScalarMultExpr class represents the compile time expression // for scaled multiplications between row-major dense matrices. */ template< typename MT1 // Type of the left-hand side dense matrix , typename MT2 // Type of the right-hand side dense matrix , bool SF // Symmetry flag , bool HF // Hermitian flag , bool LF // Lower flag , bool UF // Upper flag , typename ST > // Type of the right-hand side scalar value class DMatScalarMultExpr< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, ST, false > : public MatScalarMultExpr< DenseMatrix< DMatScalarMultExpr< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>, ST, false >, false > > , private Computation { private: //**Type definitions**************************************************************************** //! Type of the dense matrix multiplication expression. using MMM = DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>; using RES = ResultType_<MMM>; //!< Result type of the dense matrix multiplication expression. using RT1 = ResultType_<MT1>; //!< Result type of the left-hand side dense matrix expression. using RT2 = ResultType_<MT2>; //!< Result type of the right-hand side dense matrix expression. using ET1 = ElementType_<RT1>; //!< Element type of the left-hand side dense matrix expression. using ET2 = ElementType_<RT2>; //!< Element type of the right-hand side dense matrix expression. using CT1 = CompositeType_<MT1>; //!< Composite type of the left-hand side dense matrix expression. using CT2 = CompositeType_<MT2>; //!< Composite type of the right-hand side dense matrix expression. //********************************************************************************************** //********************************************************************************************** //! Compilation switch for the composite type of the left-hand side dense matrix expression. enum : bool { evaluateLeft = IsComputation<MT1>::value || RequiresEvaluation<MT1>::value }; //********************************************************************************************** //********************************************************************************************** //! Compilation switch for the composite type of the right-hand side dense matrix expression. enum : bool { evaluateRight = IsComputation<MT2>::value || RequiresEvaluation<MT2>::value }; //********************************************************************************************** //********************************************************************************************** //! Compilation switches for the kernel generation. enum : bool { SYM = ( SF && !( HF || LF || UF ) ), //!< Flag for symmetric matrices. HERM = ( HF && !( LF || UF ) ), //!< Flag for Hermitian matrices. LOW = ( LF || ( ( SF || HF ) && UF ) ), //!< Flag for lower matrices. UPP = ( UF || ( ( SF || HF ) && LF ) ) //!< Flag for upper matrices. }; //********************************************************************************************** //********************************************************************************************** //! Helper structure for the explicit application of the SFINAE principle. /*! The CanExploitSymmetry struct is a helper struct for the selection of the optimal evaluation strategy. In case the target matrix is column-major and either of the two matrix operands is symmetric, \a value is set to 1 and an optimized evaluation strategy is selected. Otherwise \a value is set to 0 and the default strategy is chosen. */ template< typename T1, typename T2, typename T3 > struct CanExploitSymmetry { enum : bool { value = IsColumnMajorMatrix<T1>::value && ( IsSymmetric<T2>::value || IsSymmetric<T3>::value ) }; }; //********************************************************************************************** //********************************************************************************************** //! Helper structure for the explicit application of the SFINAE principle. /*! The IsEvaluationRequired struct is a helper struct for the selection of the parallel evaluation strategy. In case either of the two matrix operands requires an intermediate evaluation, the nested \value will be set to 1, otherwise it will be 0. */ template< typename T1, typename T2, typename T3 > struct IsEvaluationRequired { enum : bool { value = ( evaluateLeft || evaluateRight ) && !CanExploitSymmetry<T1,T2,T3>::value }; }; //********************************************************************************************** //********************************************************************************************** //! Helper structure for the explicit application of the SFINAE principle. /*! In case the types of all three involved matrices and the scalar type are suited for a BLAS kernel, the nested \a value will be set to 1, otherwise it will be 0. */ template< typename T1, typename T2, typename T3, typename T4 > struct UseBlasKernel { enum : bool { value = BLAZE_BLAS_MODE && BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION && !SYM && !HERM && !LOW && !UPP && HasMutableDataAccess<T1>::value && HasConstDataAccess<T2>::value && HasConstDataAccess<T3>::value && !IsDiagonal<T2>::value && !IsDiagonal<T3>::value && T1::simdEnabled && T2::simdEnabled && T3::simdEnabled && IsBLASCompatible< ElementType_<T1> >::value && IsBLASCompatible< ElementType_<T2> >::value && IsBLASCompatible< ElementType_<T3> >::value && IsSame< ElementType_<T1>, ElementType_<T2> >::value && IsSame< ElementType_<T1>, ElementType_<T3> >::value && !( IsBuiltin< ElementType_<T1> >::value && IsComplex<T4>::value ) }; }; //********************************************************************************************** //********************************************************************************************** //! Helper structure for the explicit application of the SFINAE principle. /*! In case all four involved data types are suited for a vectorized computation of the matrix multiplication, the nested \value will be set to 1, otherwise it will be 0. */ template< typename T1, typename T2, typename T3, typename T4 > struct UseVectorizedDefaultKernel { enum : bool { value = useOptimizedKernels && !IsDiagonal<T3>::value && T1::simdEnabled && T2::simdEnabled && T3::simdEnabled && IsSIMDCombinable< ElementType_<T1> , ElementType_<T2> , ElementType_<T3> , T4 >::value && HasSIMDAdd< ElementType_<T2>, ElementType_<T3> >::value && HasSIMDMult< ElementType_<T2>, ElementType_<T3> >::value }; }; //********************************************************************************************** //********************************************************************************************** //! Type of the functor for forwarding an expression to another assign kernel. /*! In case a temporary matrix needs to be created, this functor is used to forward the resulting expression to another assign kernel. */ using ForwardFunctor = IfTrue_< HERM , DeclHerm , IfTrue_< SYM , DeclSym , IfTrue_< LOW , IfTrue_< UPP , DeclDiag , DeclLow > , IfTrue_< UPP , DeclUpp , Noop > > > >; //********************************************************************************************** public: //**Type definitions**************************************************************************** //! Type of this DMatScalarMultExpr instance. using This = DMatScalarMultExpr<MMM,ST,false>; using ResultType = MultTrait_<RES,ST>; //!< Result type for expression template evaluations. using OppositeType = OppositeType_<ResultType>; //!< Result type with opposite storage order for expression template evaluations. using TransposeType = TransposeType_<ResultType>; //!< Transpose type for expression template evaluations. using ElementType = ElementType_<ResultType>; //!< Resulting element type. using SIMDType = SIMDTrait_<ElementType>; //!< Resulting SIMD element type. using ReturnType = const ElementType; //!< Return type for expression template evaluations. using CompositeType = const ResultType; //!< Data type for composite expression templates. //! Composite type of the left-hand side dense matrix expression. using LeftOperand = const DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>; //! Composite type of the right-hand side scalar value. using RightOperand = ST; //! Type for the assignment of the left-hand side dense matrix operand. using LT = IfTrue_< evaluateLeft, const RT1, CT1 >; //! Type for the assignment of the right-hand side dense matrix operand. using RT = IfTrue_< evaluateRight, const RT2, CT2 >; //********************************************************************************************** //**Compilation flags*************************************************************************** //! Compilation switch for the expression template evaluation strategy. enum : bool { simdEnabled = !IsDiagonal<MT2>::value && MT1::simdEnabled && MT2::simdEnabled && IsSIMDCombinable<ET1,ET2,ST>::value && HasSIMDAdd<ET1,ET2>::value && HasSIMDMult<ET1,ET2>::value }; //! Compilation switch for the expression template assignment strategy. enum : bool { smpAssignable = !evaluateLeft && MT1::smpAssignable && !evaluateRight && MT2::smpAssignable }; //********************************************************************************************** //**SIMD properties***************************************************************************** //! The number of elements packed within a single SIMD element. enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size }; //********************************************************************************************** //**Constructor********************************************************************************* /*!\brief Constructor for the DMatScalarMultExpr class. // // \param matrix The left-hand side dense matrix of the multiplication expression. // \param scalar The right-hand side scalar of the multiplication expression. */ explicit inline DMatScalarMultExpr( const MMM& matrix, ST scalar ) : matrix_( matrix ) // Left-hand side dense matrix of the multiplication expression , scalar_( scalar ) // Right-hand side scalar of the multiplication expression {} //********************************************************************************************** //**Access operator***************************************************************************** /*!\brief 2D-access to the matrix elements. // // \param i Access index for the row. The index has to be in the range \f$[0..M-1]\f$. // \param j Access index for the column. The index has to be in the range \f$[0..N-1]\f$. // \return The resulting value. */ inline ReturnType operator()( size_t i, size_t j ) const { BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" ); BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" ); return matrix_(i,j) * scalar_; } //********************************************************************************************** //**At function********************************************************************************* /*!\brief Checked access to the matrix elements. // // \param i Access index for the row. The index has to be in the range \f$[0..M-1]\f$. // \param j Access index for the column. The index has to be in the range \f$[0..N-1]\f$. // \return The resulting value. // \exception std::out_of_range Invalid matrix access index. */ inline ReturnType at( size_t i, size_t j ) const { if( i >= matrix_.rows() ) { BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" ); } if( j >= matrix_.columns() ) { BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" ); } return (*this)(i,j); } //********************************************************************************************** //**Rows function******************************************************************************* /*!\brief Returns the current number of rows of the matrix. // // \return The number of rows of the matrix. */ inline size_t rows() const { return matrix_.rows(); } //********************************************************************************************** //**Columns function**************************************************************************** /*!\brief Returns the current number of columns of the matrix. // // \return The number of columns of the matrix. */ inline size_t columns() const { return matrix_.columns(); } //********************************************************************************************** //**Left operand access************************************************************************* /*!\brief Returns the left-hand side dense matrix operand. // // \return The left-hand side dense matrix operand. */ inline LeftOperand leftOperand() const { return matrix_; } //********************************************************************************************** //**Right operand access************************************************************************ /*!\brief Returns the right-hand side scalar operand. // // \return The right-hand side scalar operand. */ inline RightOperand rightOperand() const { return scalar_; } //********************************************************************************************** //********************************************************************************************** /*!\brief Returns whether the expression can alias with the given address \a alias. // // \param alias The alias to be checked. // \return \a true in case the expression can alias, \a false otherwise. */ template< typename T > inline bool canAlias( const T* alias ) const { return matrix_.canAlias( alias ); } //********************************************************************************************** //********************************************************************************************** /*!\brief Returns whether the expression is aliased with the given address \a alias. // // \param alias The alias to be checked. // \return \a true in case an alias effect is detected, \a false otherwise. */ template< typename T > inline bool isAliased( const T* alias ) const { return matrix_.isAliased( alias ); } //********************************************************************************************** //********************************************************************************************** /*!\brief Returns whether the operands of the expression are properly aligned in memory. // // \return \a true in case the operands are aligned, \a false if not. */ inline bool isAligned() const { return matrix_.isAligned(); } //********************************************************************************************** //********************************************************************************************** /*!\brief Returns whether the expression can be used in SMP assignments. // // \return \a true in case the expression can be used in SMP assignments, \a false if not. */ inline bool canSMPAssign() const noexcept { return ( !BLAZE_BLAS_MODE || !BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION || !BLAZE_BLAS_IS_PARALLEL || ( rows() * columns() < DMATDMATMULT_THRESHOLD ) ) && ( rows() * columns() >= SMP_DMATDMATMULT_THRESHOLD ); } //********************************************************************************************** private: //**Member variables**************************************************************************** LeftOperand matrix_; //!< Left-hand side dense matrix of the multiplication expression. RightOperand scalar_; //!< Right-hand side scalar of the multiplication expression. //********************************************************************************************** //**Assignment to dense matrices**************************************************************** /*!\brief Assignment of a scaled dense matrix-dense matrix multiplication to a dense matrix // (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side scaled multiplication expression to be assigned. // \return void // // This function implements the performance optimized assignment of a scaled dense matrix- // dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> > assign( DenseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL ) { return; } else if( left.columns() == 0UL ) { reset( ~lhs ); return; } LT A( serial( left ) ); // Evaluation of the left-hand side dense matrix operand RT B( serial( right ) ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == left.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == left.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == right.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == right.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns(), "Invalid number of columns" ); DMatScalarMultExpr::selectAssignKernel( ~lhs, A, B, rhs.scalar_ ); } //********************************************************************************************** //**Assignment to dense matrices (kernel selection)********************************************* /*!\brief Selection of the kernel for an assignment of a scaled dense matrix-dense matrix // multiplication to a dense matrix (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline void selectAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { if( ( IsDiagonal<MT5>::value ) || ( !BLAZE_DEBUG_MODE && B.columns() <= SIMDSIZE*10UL ) || ( C.rows() * C.columns() < DMATDMATMULT_THRESHOLD ) ) selectSmallAssignKernel( C, A, B, scalar ); else selectBlasAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Default assignment to dense matrices (general/general)************************************** /*!\brief Default assignment of a scaled general dense matrix-general dense matrix // multiplication (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default assignment of a scaled general dense matrix-general // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< Not< IsDiagonal<MT4> >, Not< IsDiagonal<MT5> > > > selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( SYM || HERM || LOW || UPP ) || ( M == N ), "Broken invariant detected" ); for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( K ) ); BLAZE_INTERNAL_ASSERT( kbegin <= kend, "Invalid loop indices detected" ); if( IsStrictlyTriangular<MT4>::value && kbegin == kend ) { for( size_t j=0UL; j<N; ++j ) { reset( C(i,j) ); } continue; } { const size_t jbegin( ( IsUpper<MT5>::value ) ?( ( IsStrictlyUpper<MT5>::value ) ?( UPP ? max(i,kbegin+1UL) : kbegin+1UL ) :( UPP ? max(i,kbegin) : kbegin ) ) :( UPP ? i : 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( ( IsStrictlyLower<MT5>::value ) ?( LOW ? min(i+1UL,kbegin) : kbegin ) :( LOW ? min(i,kbegin)+1UL : kbegin+1UL ) ) :( LOW ? i+1UL : N ) ); if( ( IsUpper<MT4>::value && IsUpper<MT5>::value ) || UPP ) { for( size_t j=0UL; j<jbegin; ++j ) { reset( C(i,j) ); } } else if( IsStrictlyUpper<MT5>::value ) { reset( C(i,0UL) ); } for( size_t j=jbegin; j<jend; ++j ) { C(i,j) = A(i,kbegin) * B(kbegin,j); } if( ( IsLower<MT4>::value && IsLower<MT5>::value ) || LOW ) { for( size_t j=jend; j<N; ++j ) { reset( C(i,j) ); } } else if( IsStrictlyLower<MT5>::value ) { reset( C(i,N-1UL) ); } } for( size_t k=kbegin+1UL; k<kend; ++k ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( ( IsStrictlyUpper<MT5>::value ) ?( SYM || HERM || UPP ? max( i, k+1UL ) : k+1UL ) :( SYM || HERM || UPP ? max( i, k ) : k ) ) :( SYM || HERM || UPP ? i : 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( ( IsStrictlyLower<MT5>::value ) ?( LOW ? min(i+1UL,k-1UL) : k-1UL ) :( LOW ? min(i+1UL,k) : k ) ) :( LOW ? i+1UL : N ) ); if( ( SYM || HERM || LOW || UPP ) && ( jbegin > jend ) ) continue; BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); for( size_t j=jbegin; j<jend; ++j ) { C(i,j) += A(i,k) * B(k,j); } if( IsLower<MT5>::value ) { C(i,jend) = A(i,k) * B(k,jend); } } { const size_t jbegin( ( IsUpper<MT4>::value && IsUpper<MT5>::value ) ?( IsStrictlyUpper<MT4>::value || IsStrictlyUpper<MT5>::value ? i+1UL : i ) :( SYM || HERM || UPP ? i : 0UL ) ); const size_t jend( ( IsLower<MT4>::value && IsLower<MT5>::value ) ?( IsStrictlyLower<MT4>::value || IsStrictlyLower<MT5>::value ? i : i+1UL ) :( LOW ? i+1UL : N ) ); if( ( SYM || HERM || LOW || UPP ) && ( jbegin > jend ) ) continue; BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); for( size_t j=jbegin; j<jend; ++j ) { C(i,j) *= scalar; } } } if( SYM || HERM ) { for( size_t i=1UL; i<M; ++i ) { for( size_t j=0UL; j<i; ++j ) { C(i,j) = HERM ? conj( C(j,i) ) : C(j,i); } } } } //********************************************************************************************** //**Default assignment to dense matrices (general/diagonal)************************************* /*!\brief Default assignment of a scaled general dense matrix-diagonal dense matrix // multiplication (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default assignment of a scaled general dense matrix-diagonal // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< Not< IsDiagonal<MT4> >, IsDiagonal<MT5> > > selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); if( IsUpper<MT4>::value ) { for( size_t j=0UL; j<jbegin; ++j ) { reset( C(i,j) ); } } for( size_t j=jbegin; j<jend; ++j ) { C(i,j) = A(i,j) * B(j,j) * scalar; } if( IsLower<MT4>::value ) { for( size_t j=jend; j<N; ++j ) { reset( C(i,j) ); } } } } //********************************************************************************************** //**Default assignment to dense matrices (diagonal/general)************************************* /*!\brief Default assignment of a scaled diagonal dense matrix-general dense matrix // multiplication (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default assignment of a scaled diagonal dense matrix-general // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< IsDiagonal<MT4>, Not< IsDiagonal<MT5> > > > selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( IsStrictlyUpper<MT5>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( IsStrictlyLower<MT5>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); if( IsUpper<MT5>::value ) { for( size_t j=0UL; j<jbegin; ++j ) { reset( C(i,j) ); } } for( size_t j=jbegin; j<jend; ++j ) { C(i,j) = A(i,i) * B(i,j) * scalar; } if( IsLower<MT5>::value ) { for( size_t j=jend; j<N; ++j ) { reset( C(i,j) ); } } } } //********************************************************************************************** //**Default assignment to dense matrices (diagonal/diagonal)************************************ /*!\brief Default assignment of a scaled diagonal dense matrix-diagonal dense matrix // multiplication (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default assignment of a scaled diagonal dense matrix-diagional // dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< IsDiagonal<MT4>, IsDiagonal<MT5> > > selectDefaultAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); reset( C ); for( size_t i=0UL; i<A.rows(); ++i ) { C(i,i) = A(i,i) * B(i,i) * scalar; } } //********************************************************************************************** //**Default assignment to dense matrices (small matrices)*************************************** /*!\brief Default assignment of a small scaled dense matrix-dense matrix multiplication // (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the assignment of a scaled dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectDefaultAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Vectorized default assignment to row-major dense matrices (small matrices)****************** /*!\brief Vectorized default assignment of a small scaled dense matrix-dense matrix // multiplication (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default assignment of a scaled dense matrix-dense // matrix multiplication expression to a row-major dense matrix. This kernel is optimized for // small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallAssignKernel( DenseMatrix<MT3,false>& C, const MT4& A, const MT5& B, ST2 scalar ) { constexpr bool remainder( !IsPadded<MT3>::value || !IsPadded<MT5>::value ); const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( SYM || HERM || LOW || UPP ) || ( M == N ), "Broken invariant detected" ); const size_t jpos( remainder ? ( N & size_t(-SIMDSIZE) ) : N ); BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % SIMDSIZE ) ) == jpos, "Invalid end calculation" ); const SIMDType factor( set( scalar ) ); if( LOW && UPP && N > SIMDSIZE*3UL ) { reset( ~C ); } { size_t j( 0UL ); if( IsIntegral<ElementType>::value ) { for( ; !SYM && !HERM && !LOW && !UPP && (j+SIMDSIZE*7UL) < jpos; j+=SIMDSIZE*8UL ) { for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i : i+1UL ), j+SIMDSIZE*8UL, K ) ) :( IsStrictlyLower<MT4>::value ? i : i+1UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*8UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); xmm6 += a1 * B.load(k,j+SIMDSIZE*5UL); xmm7 += a1 * B.load(k,j+SIMDSIZE*6UL); xmm8 += a1 * B.load(k,j+SIMDSIZE*7UL); } (~C).store( i, j , xmm1 * factor ); (~C).store( i, j+SIMDSIZE , xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 * factor ); (~C).store( i, j+SIMDSIZE*4UL, xmm5 * factor ); (~C).store( i, j+SIMDSIZE*5UL, xmm6 * factor ); (~C).store( i, j+SIMDSIZE*6UL, xmm7 * factor ); (~C).store( i, j+SIMDSIZE*7UL, xmm8 * factor ); } } } for( ; !SYM && !HERM && !LOW && !UPP && (j+SIMDSIZE*4UL) < jpos; j+=SIMDSIZE*5UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*5UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*5UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); const SIMDType b5( B.load(k,j+SIMDSIZE*4UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a1 * b5; xmm6 += a2 * b1; xmm7 += a2 * b2; xmm8 += a2 * b3; xmm9 += a2 * b4; xmm10 += a2 * b5; } (~C).store( i , j , xmm1 * factor ); (~C).store( i , j+SIMDSIZE , xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 * factor ); (~C).store( i , j+SIMDSIZE*3UL, xmm4 * factor ); (~C).store( i , j+SIMDSIZE*4UL, xmm5 * factor ); (~C).store( i+1UL, j , xmm6 * factor ); (~C).store( i+1UL, j+SIMDSIZE , xmm7 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm8 * factor ); (~C).store( i+1UL, j+SIMDSIZE*3UL, xmm9 * factor ); (~C).store( i+1UL, j+SIMDSIZE*4UL, xmm10 * factor ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*5UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); } (~C).store( i, j , xmm1 * factor ); (~C).store( i, j+SIMDSIZE , xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 * factor ); (~C).store( i, j+SIMDSIZE*4UL, xmm5 * factor ); } } for( ; !( LOW && UPP ) && (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) { const size_t iend( SYM || HERM || UPP ? min(j+SIMDSIZE*4UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*4UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*4UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a2 * b1; xmm6 += a2 * b2; xmm7 += a2 * b3; xmm8 += a2 * b4; } (~C).store( i , j , xmm1 * factor ); (~C).store( i , j+SIMDSIZE , xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 * factor ); (~C).store( i , j+SIMDSIZE*3UL, xmm4 * factor ); (~C).store( i+1UL, j , xmm5 * factor ); (~C).store( i+1UL, j+SIMDSIZE , xmm6 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm7 * factor ); (~C).store( i+1UL, j+SIMDSIZE*3UL, xmm8 * factor ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*4UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); } (~C).store( i, j , xmm1 * factor ); (~C).store( i, j+SIMDSIZE , xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, xmm4 * factor ); } } for( ; (j+SIMDSIZE*2UL) < jpos; j+=SIMDSIZE*3UL ) { const size_t iend( SYM || HERM || UPP ? min(j+SIMDSIZE*3UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*3UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*3UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a2 * b1; xmm5 += a2 * b2; xmm6 += a2 * b3; } (~C).store( i , j , xmm1 * factor ); (~C).store( i , j+SIMDSIZE , xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, xmm3 * factor ); (~C).store( i+1UL, j , xmm4 * factor ); (~C).store( i+1UL, j+SIMDSIZE , xmm5 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, xmm6 * factor ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*3UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); } (~C).store( i, j , xmm1 * factor ); (~C).store( i, j+SIMDSIZE , xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, xmm3 * factor ); } } for( ; (j+SIMDSIZE) < jpos; j+=SIMDSIZE*2UL ) { const size_t iend( SYM || HERM || UPP ? min(j+SIMDSIZE*2UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType a4( set( A(i+3UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; xmm7 += a4 * b1; xmm8 += a4 * b2; } (~C).store( i , j , xmm1 * factor ); (~C).store( i , j+SIMDSIZE, xmm2 * factor ); (~C).store( i+1UL, j , xmm3 * factor ); (~C).store( i+1UL, j+SIMDSIZE, xmm4 * factor ); (~C).store( i+2UL, j , xmm5 * factor ); (~C).store( i+2UL, j+SIMDSIZE, xmm6 * factor ); (~C).store( i+3UL, j , xmm7 * factor ); (~C).store( i+3UL, j+SIMDSIZE, xmm8 * factor ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; } (~C).store( i , j , xmm1 * factor ); (~C).store( i , j+SIMDSIZE, xmm2 * factor ); (~C).store( i+1UL, j , xmm3 * factor ); (~C).store( i+1UL, j+SIMDSIZE, xmm4 * factor ); (~C).store( i+2UL, j , xmm5 * factor ); (~C).store( i+2UL, j+SIMDSIZE, xmm6 * factor ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i ,k ) ) ); const SIMDType a2( set( A(i+1UL,k ) ) ); const SIMDType a3( set( A(i ,k+1UL) ) ); const SIMDType a4( set( A(i+1UL,k+1UL) ) ); const SIMDType b1( B.load(k ,j ) ); const SIMDType b2( B.load(k ,j+SIMDSIZE) ); const SIMDType b3( B.load(k+1UL,j ) ); const SIMDType b4( B.load(k+1UL,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b3; xmm6 += a3 * b4; xmm7 += a4 * b3; xmm8 += a4 * b4; } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; } (~C).store( i , j , (xmm1+xmm5) * factor ); (~C).store( i , j+SIMDSIZE, (xmm2+xmm6) * factor ); (~C).store( i+1UL, j , (xmm3+xmm7) * factor ); (~C).store( i+1UL, j+SIMDSIZE, (xmm4+xmm8) * factor ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*2UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i,k ) ) ); const SIMDType a2( set( A(i,k+1UL) ) ); xmm1 += a1 * B.load(k ,j ); xmm2 += a1 * B.load(k ,j+SIMDSIZE); xmm3 += a2 * B.load(k+1UL,j ); xmm4 += a2 * B.load(k+1UL,j+SIMDSIZE); } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE); } (~C).store( i, j , (xmm1+xmm3) * factor ); (~C).store( i, j+SIMDSIZE, (xmm2+xmm4) * factor ); } } for( ; j<jpos; j+=SIMDSIZE ) { const size_t iend( SYM || HERM || UPP ? min(j+SIMDSIZE,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i+3UL,k ) ) * b1; xmm5 += set( A(i ,k+1UL) ) * b2; xmm6 += set( A(i+1UL,k+1UL) ) * b2; xmm7 += set( A(i+2UL,k+1UL) ) * b2; xmm8 += set( A(i+3UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; xmm4 += set( A(i+3UL,k) ) * b1; } (~C).store( i , j, (xmm1+xmm5) * factor ); (~C).store( i+1UL, j, (xmm2+xmm6) * factor ); (~C).store( i+2UL, j, (xmm3+xmm7) * factor ); (~C).store( i+3UL, j, (xmm4+xmm8) * factor ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i ,k+1UL) ) * b2; xmm5 += set( A(i+1UL,k+1UL) ) * b2; xmm6 += set( A(i+2UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; } (~C).store( i , j, (xmm1+xmm4) * factor ); (~C).store( i+1UL, j, (xmm2+xmm5) * factor ); (~C).store( i+2UL, j, (xmm3+xmm6) * factor ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i ,k+1UL) ) * b2; xmm4 += set( A(i+1UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; } (~C).store( i , j, (xmm1+xmm3) * factor ); (~C).store( i+1UL, j, (xmm2+xmm4) * factor ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); SIMDType xmm1, xmm2; size_t k( kbegin ); for( ; (k+2UL) <= K; k+=2UL ) { xmm1 += set( A(i,k ) ) * B.load(k ,j); xmm2 += set( A(i,k+1UL) ) * B.load(k+1UL,j); } for( ; k<K; ++k ) { xmm1 += set( A(i,k) ) * B.load(k,j); } (~C).store( i, j, (xmm1+xmm2) * factor ); } } for( ; remainder && j<N; ++j ) { size_t i( LOW && UPP ? j : 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); ElementType value1 = ElementType(); ElementType value2 = ElementType(); for( size_t k=kbegin; k<kend; ++k ) { value1 += A(i ,k) * B(k,j); value2 += A(i+1UL,k) * B(k,j); } (~C)(i ,j) = value1 * scalar; (~C)(i+1UL,j) = value2 * scalar; } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); ElementType value = ElementType(); for( size_t k=kbegin; k<K; ++k ) { value += A(i,k) * B(k,j); } (~C)(i,j) = value * scalar; } } } if( ( SYM || HERM ) && ( N > SIMDSIZE*4UL ) ) { for( size_t i=SIMDSIZE*4UL; i<M; ++i ) { const size_t jend( ( SIMDSIZE*4UL ) * ( i / (SIMDSIZE*4UL) ) ); for( size_t j=0UL; j<jend; ++j ) { (~C)(i,j) = HERM ? conj( (~C)(j,i) ) : (~C)(j,i); } } } else if( LOW && !UPP && N > SIMDSIZE*4UL ) { for( size_t j=SIMDSIZE*4UL; j<N; ++j ) { const size_t iend( ( SIMDSIZE*4UL ) * ( j / (SIMDSIZE*4UL) ) ); for( size_t i=0UL; i<iend; ++i ) { reset( (~C)(i,j) ); } } } else if( !LOW && UPP && N > SIMDSIZE*4UL ) { for( size_t i=SIMDSIZE*4UL; i<M; ++i ) { const size_t jend( ( SIMDSIZE*4UL ) * ( i / (SIMDSIZE*4UL) ) ); for( size_t j=0UL; j<jend; ++j ) { reset( (~C)(i,j) ); } } } } //********************************************************************************************** //**Vectorized default assignment to column-major dense matrices (small matrices)*************** /*!\brief Vectorized default assignment of a small scaled dense matrix-dense matrix // multiplication (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default assignment of a small scaled dense matrix- // dense matrix multiplication expression to a column-major dense matrix. This kernel is // optimized for small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallAssignKernel( DenseMatrix<MT3,true>& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT4 ); BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT5 ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT4> ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT5> ); const ForwardFunctor fwd; if( !IsResizable<MT4>::value && IsResizable<MT5>::value ) { const OppositeType_<MT4> tmp( serial( A ) ); assign( ~C, fwd( tmp * B ) * scalar ); } else if( IsResizable<MT4>::value && !IsResizable<MT5>::value ) { const OppositeType_<MT5> tmp( serial( B ) ); assign( ~C, fwd( A * tmp ) * scalar ); } else if( A.rows() * A.columns() <= B.rows() * B.columns() ) { const OppositeType_<MT4> tmp( serial( A ) ); assign( ~C, fwd( tmp * B ) * scalar ); } else { const OppositeType_<MT5> tmp( serial( B ) ); assign( ~C, fwd( A * tmp ) * scalar ); } } //********************************************************************************************** //**Default assignment to dense matrices (large matrices)*************************************** /*!\brief Default assignment of a large scaled dense matrix-dense matrix multiplication // (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the assignment of a scaled dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectDefaultAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Vectorized default assignment to dense matrices (large matrices)**************************** /*!\brief Vectorized default assignment of a large scaled dense matrix-dense matrix // multiplication (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default assignment of a scaled dense matrix-dense // matrix multiplication expression to a dense matrix. This kernel is optimized for large // matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectLargeAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { if( SYM ) smmm( C, A, B, scalar ); else if( HERM ) hmmm( C, A, B, scalar ); else if( LOW ) lmmm( C, A, B, scalar, ST2(0) ); else if( UPP ) ummm( C, A, B, scalar, ST2(0) ); else mmm( C, A, B, scalar, ST2(0) ); } //********************************************************************************************** //**BLAS-based assignment to dense matrices (default)******************************************* /*!\brief Default assignment of a scaled dense matrix-dense matrix multiplication // (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the assignment of a large scaled // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseBlasKernel<MT3,MT4,MT5,ST2> > selectBlasAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectLargeAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**BLAS-based assignment to dense matrices***************************************************** #if BLAZE_BLAS_MODE && BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION /*!\brief BLAS-based assignment of a scaled dense matrix-dense matrix multiplication // (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function performs the scaled dense matrix-dense matrix multiplication based on the // according BLAS functionality. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseBlasKernel<MT3,MT4,MT5,ST2> > selectBlasAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { using ET = ElementType_<MT3>; if( IsTriangular<MT4>::value ) { assign( C, B ); trmm( C, A, CblasLeft, ( IsLower<MT4>::value )?( CblasLower ):( CblasUpper ), ET(scalar) ); } else if( IsTriangular<MT5>::value ) { assign( C, A ); trmm( C, B, CblasRight, ( IsLower<MT5>::value )?( CblasLower ):( CblasUpper ), ET(scalar) ); } else { gemm( C, A, B, ET(scalar), ET(0) ); } } #endif //********************************************************************************************** //**Assignment to sparse matrices*************************************************************** /*!\brief Assignment of a scaled dense matrix-dense matrix multiplication to a sparse matrix // (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side sparse matrix. // \param rhs The right-hand side scaled multiplication expression to be assigned. // \return void // // This function implements the performance optimized assignment of a scaled dense matrix- // dense matrix multiplication expression to a sparse matrix. */ template< typename MT // Type of the target sparse matrix , bool SO > // Storage order of the target sparse matrix friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> > assign( SparseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; using TmpType = IfTrue_< SO, OppositeType, ResultType >; BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( OppositeType ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType ); BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER( MT, TmpType ); BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( TmpType ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; const TmpType tmp( serial( rhs ) ); assign( ~lhs, fwd( tmp ) ); } //********************************************************************************************** //**Restructuring assignment to column-major matrices******************************************* /*!\brief Restructuring assignment of a scaled dense matrix-dense matrix multiplication to a // column-major matrix (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side scaled multiplication expression to be assigned. // \return void // // This function implements the symmetry-based restructuring assignment of a scaled dense // matrix-dense matrix multiplication expression to a column-major matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler in // case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > assign( Matrix<MT,true>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) assign( ~lhs, fwd( trans( left ) * trans( right ) ) * rhs.scalar_ ); else if( IsSymmetric<MT1>::value ) assign( ~lhs, fwd( trans( left ) * right ) * rhs.scalar_ ); else assign( ~lhs, fwd( left * trans( right ) ) * rhs.scalar_ ); } //********************************************************************************************** //**Addition assignment to dense matrices******************************************************* /*!\brief Addition assignment of a scaled dense matrix-dense matrix multiplication to a // dense matrix (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side scaled multiplication expression to be added. // \return void // // This function implements the performance optimized addition assignment of a scaled dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> > addAssign( DenseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL || left.columns() == 0UL ) { return; } LT A( serial( left ) ); // Evaluation of the left-hand side dense matrix operand RT B( serial( right ) ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == left.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == left.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == right.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == right.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns(), "Invalid number of columns" ); DMatScalarMultExpr::selectAddAssignKernel( ~lhs, A, B, rhs.scalar_ ); } //********************************************************************************************** //**Addition assignment to dense matrices (kernel selection)************************************ /*!\brief Selection of the kernel for an addition assignment of a scaled dense matrix-dense // matrix multiplication to a dense matrix (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline void selectAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { if( ( IsDiagonal<MT5>::value ) || ( !BLAZE_DEBUG_MODE && B.columns() <= SIMDSIZE*10UL ) || ( C.rows() * C.columns() < DMATDMATMULT_THRESHOLD ) ) selectSmallAddAssignKernel( C, A, B, scalar ); else selectBlasAddAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Default addition assignment to dense matrices (general/general)***************************** /*!\brief Default addition assignment of a scaled general dense matrix-general dense matrix // multiplication (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default addition assignment of a scaled dense matrix-dense // matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< Not< IsDiagonal<MT4> >, Not< IsDiagonal<MT5> > > > selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { const ResultType tmp( serial( A * B * scalar ) ); addAssign( C, tmp ); } //********************************************************************************************** //**Default addition assignment to dense matrices (general/diagonal)**************************** /*!\brief Default addition assignment of a scaled general dense matrix-diagonal dense matrix // multiplication (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default addition assignment of a scaled general dense matrix- // diagonal dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< Not< IsDiagonal<MT4> >, IsDiagonal<MT5> > > selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) += A(i,j ) * B(j ,j ) * scalar; C(i,j+1UL) += A(i,j+1UL) * B(j+1UL,j+1UL) * scalar; } if( jpos < jend ) { C(i,jpos) += A(i,jpos) * B(jpos,jpos) * scalar; } } } //********************************************************************************************** //**Default addition assignment to dense matrices (diagonal/general)**************************** /*!\brief Default addition assignment of a scaled diagonal dense matrix-general dense matrix // multiplication (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default addition assignment of a scaled diagonal dense matrix- // general dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< IsDiagonal<MT4>, Not< IsDiagonal<MT5> > > > selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( IsStrictlyUpper<MT5>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( IsStrictlyLower<MT5>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) += A(i,i) * B(i,j ) * scalar; C(i,j+1UL) += A(i,i) * B(i,j+1UL) * scalar; } if( jpos < jend ) { C(i,jpos) += A(i,i) * B(i,jpos) * scalar; } } } //********************************************************************************************** //**Default addition assignment to dense matrices (diagonal/diagonal)*************************** /*!\brief Default addition assignment of a scaled diagonal dense matrix-diagonal dense matrix // multiplication (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default addition assignment of a scaled diagonal dense matrix- // diagonal dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< IsDiagonal<MT4>, IsDiagonal<MT5> > > selectDefaultAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); for( size_t i=0UL; i<A.rows(); ++i ) { C(i,i) += A(i,i) * B(i,i) * scalar; } } //********************************************************************************************** //**Default addition assignment to dense matrices (small matrices)****************************** /*!\brief Default addition assignment of a small scaled dense matrix-dense matrix multiplication // (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the addition assignment of a scaled // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectDefaultAddAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Vectorized default addition assignment to row-major dense matrices (small matrices)********* /*!\brief Vectorized default addition assignment of a small scaled dense matrix-dense matrix // multiplication (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default addition assignment of a scaled dense // matrix-dense matrix multiplication expression to a row-major dense matrix. This kernel // is optimized for small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallAddAssignKernel( DenseMatrix<MT3,false>& C, const MT4& A, const MT5& B, ST2 scalar ) { constexpr bool remainder( !IsPadded<MT3>::value || !IsPadded<MT5>::value ); const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( LOW || UPP ) || ( M == N ), "Broken invariant detected" ); const size_t jpos( remainder ? ( N & size_t(-SIMDSIZE) ) : N ); BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % SIMDSIZE ) ) == jpos, "Invalid end calculation" ); const SIMDType factor( set( scalar ) ); size_t j( 0UL ); if( IsIntegral<ElementType>::value ) { for( ; !LOW && !UPP && (j+SIMDSIZE*7UL) < jpos; j+=SIMDSIZE*8UL ) { for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i : i+1UL ), j+SIMDSIZE*8UL, K ) ) :( IsStrictlyLower<MT4>::value ? i : i+1UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*8UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); xmm6 += a1 * B.load(k,j+SIMDSIZE*5UL); xmm7 += a1 * B.load(k,j+SIMDSIZE*6UL); xmm8 += a1 * B.load(k,j+SIMDSIZE*7UL); } (~C).store( i, j , (~C).load(i,j ) + xmm1 * factor ); (~C).store( i, j+SIMDSIZE , (~C).load(i,j+SIMDSIZE ) + xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, (~C).load(i,j+SIMDSIZE*2UL) + xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, (~C).load(i,j+SIMDSIZE*3UL) + xmm4 * factor ); (~C).store( i, j+SIMDSIZE*4UL, (~C).load(i,j+SIMDSIZE*4UL) + xmm5 * factor ); (~C).store( i, j+SIMDSIZE*5UL, (~C).load(i,j+SIMDSIZE*5UL) + xmm6 * factor ); (~C).store( i, j+SIMDSIZE*6UL, (~C).load(i,j+SIMDSIZE*6UL) + xmm7 * factor ); (~C).store( i, j+SIMDSIZE*7UL, (~C).load(i,j+SIMDSIZE*7UL) + xmm8 * factor ); } } } for( ; !LOW && !UPP && (j+SIMDSIZE*4UL) < jpos; j+=SIMDSIZE*5UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*5UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*5UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); const SIMDType b5( B.load(k,j+SIMDSIZE*4UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a1 * b5; xmm6 += a2 * b1; xmm7 += a2 * b2; xmm8 += a2 * b3; xmm9 += a2 * b4; xmm10 += a2 * b5; } (~C).store( i , j , (~C).load(i ,j ) + xmm1 * factor ); (~C).store( i , j+SIMDSIZE , (~C).load(i ,j+SIMDSIZE ) + xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, (~C).load(i ,j+SIMDSIZE*2UL) + xmm3 * factor ); (~C).store( i , j+SIMDSIZE*3UL, (~C).load(i ,j+SIMDSIZE*3UL) + xmm4 * factor ); (~C).store( i , j+SIMDSIZE*4UL, (~C).load(i ,j+SIMDSIZE*4UL) + xmm5 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) + xmm6 * factor ); (~C).store( i+1UL, j+SIMDSIZE , (~C).load(i+1UL,j+SIMDSIZE ) + xmm7 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, (~C).load(i+1UL,j+SIMDSIZE*2UL) + xmm8 * factor ); (~C).store( i+1UL, j+SIMDSIZE*3UL, (~C).load(i+1UL,j+SIMDSIZE*3UL) + xmm9 * factor ); (~C).store( i+1UL, j+SIMDSIZE*4UL, (~C).load(i+1UL,j+SIMDSIZE*4UL) + xmm10 * factor ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*5UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); } (~C).store( i, j , (~C).load(i,j ) + xmm1 * factor ); (~C).store( i, j+SIMDSIZE , (~C).load(i,j+SIMDSIZE ) + xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, (~C).load(i,j+SIMDSIZE*2UL) + xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, (~C).load(i,j+SIMDSIZE*3UL) + xmm4 * factor ); (~C).store( i, j+SIMDSIZE*4UL, (~C).load(i,j+SIMDSIZE*4UL) + xmm5 * factor ); } } for( ; !LOW && !UPP && (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*4UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*4UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a2 * b1; xmm6 += a2 * b2; xmm7 += a2 * b3; xmm8 += a2 * b4; } (~C).store( i , j , (~C).load(i ,j ) + xmm1 * factor ); (~C).store( i , j+SIMDSIZE , (~C).load(i ,j+SIMDSIZE ) + xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, (~C).load(i ,j+SIMDSIZE*2UL) + xmm3 * factor ); (~C).store( i , j+SIMDSIZE*3UL, (~C).load(i ,j+SIMDSIZE*3UL) + xmm4 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) + xmm5 * factor ); (~C).store( i+1UL, j+SIMDSIZE , (~C).load(i+1UL,j+SIMDSIZE ) + xmm6 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, (~C).load(i+1UL,j+SIMDSIZE*2UL) + xmm7 * factor ); (~C).store( i+1UL, j+SIMDSIZE*3UL, (~C).load(i+1UL,j+SIMDSIZE*3UL) + xmm8 * factor ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*4UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); } (~C).store( i, j , (~C).load(i,j ) + xmm1 * factor ); (~C).store( i, j+SIMDSIZE , (~C).load(i,j+SIMDSIZE ) + xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, (~C).load(i,j+SIMDSIZE*2UL) + xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, (~C).load(i,j+SIMDSIZE*3UL) + xmm4 * factor ); } } for( ; !LOW && !UPP && (j+SIMDSIZE*2UL) < jpos; j+=SIMDSIZE*3UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*3UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*3UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a2 * b1; xmm5 += a2 * b2; xmm6 += a2 * b3; } (~C).store( i , j , (~C).load(i ,j ) + xmm1 * factor ); (~C).store( i , j+SIMDSIZE , (~C).load(i ,j+SIMDSIZE ) + xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, (~C).load(i ,j+SIMDSIZE*2UL) + xmm3 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) + xmm4 * factor ); (~C).store( i+1UL, j+SIMDSIZE , (~C).load(i+1UL,j+SIMDSIZE ) + xmm5 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, (~C).load(i+1UL,j+SIMDSIZE*2UL) + xmm6 * factor ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*3UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); } (~C).store( i, j , (~C).load(i,j ) + xmm1 * factor ); (~C).store( i, j+SIMDSIZE , (~C).load(i,j+SIMDSIZE ) + xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, (~C).load(i,j+SIMDSIZE*2UL) + xmm3 * factor ); } } for( ; !( LOW && UPP ) && (j+SIMDSIZE) < jpos; j+=SIMDSIZE*2UL ) { const size_t iend( UPP ? min(j+SIMDSIZE*2UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType a4( set( A(i+3UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; xmm7 += a4 * b1; xmm8 += a4 * b2; } (~C).store( i , j , (~C).load(i ,j ) + xmm1 * factor ); (~C).store( i , j+SIMDSIZE, (~C).load(i ,j+SIMDSIZE) + xmm2 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) + xmm3 * factor ); (~C).store( i+1UL, j+SIMDSIZE, (~C).load(i+1UL,j+SIMDSIZE) + xmm4 * factor ); (~C).store( i+2UL, j , (~C).load(i+2UL,j ) + xmm5 * factor ); (~C).store( i+2UL, j+SIMDSIZE, (~C).load(i+2UL,j+SIMDSIZE) + xmm6 * factor ); (~C).store( i+3UL, j , (~C).load(i+3UL,j ) + xmm7 * factor ); (~C).store( i+3UL, j+SIMDSIZE, (~C).load(i+3UL,j+SIMDSIZE) + xmm8 * factor ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; } (~C).store( i , j , (~C).load(i ,j ) + xmm1 * factor ); (~C).store( i , j+SIMDSIZE, (~C).load(i ,j+SIMDSIZE) + xmm2 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) + xmm3 * factor ); (~C).store( i+1UL, j+SIMDSIZE, (~C).load(i+1UL,j+SIMDSIZE) + xmm4 * factor ); (~C).store( i+2UL, j , (~C).load(i+2UL,j ) + xmm5 * factor ); (~C).store( i+2UL, j+SIMDSIZE, (~C).load(i+2UL,j+SIMDSIZE) + xmm6 * factor ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i ,k ) ) ); const SIMDType a2( set( A(i+1UL,k ) ) ); const SIMDType a3( set( A(i ,k+1UL) ) ); const SIMDType a4( set( A(i+1UL,k+1UL) ) ); const SIMDType b1( B.load(k ,j ) ); const SIMDType b2( B.load(k ,j+SIMDSIZE) ); const SIMDType b3( B.load(k+1UL,j ) ); const SIMDType b4( B.load(k+1UL,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b3; xmm6 += a3 * b4; xmm7 += a4 * b3; xmm8 += a4 * b4; } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; } (~C).store( i , j , (~C).load(i ,j ) + (xmm1+xmm5) * factor ); (~C).store( i , j+SIMDSIZE, (~C).load(i ,j+SIMDSIZE) + (xmm2+xmm6) * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) + (xmm3+xmm7) * factor ); (~C).store( i+1UL, j+SIMDSIZE, (~C).load(i+1UL,j+SIMDSIZE) + (xmm4+xmm8) * factor ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*2UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i,k ) ) ); const SIMDType a2( set( A(i,k+1UL) ) ); xmm1 += a1 * B.load(k ,j ); xmm2 += a1 * B.load(k ,j+SIMDSIZE); xmm3 += a2 * B.load(k+1UL,j ); xmm4 += a2 * B.load(k+1UL,j+SIMDSIZE); } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE); } (~C).store( i, j , (~C).load(i,j ) + (xmm1+xmm3) * factor ); (~C).store( i, j+SIMDSIZE, (~C).load(i,j+SIMDSIZE) + (xmm2+xmm4) * factor ); } } for( ; j<jpos; j+=SIMDSIZE ) { const size_t iend( LOW && UPP ? min(j+SIMDSIZE,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i+3UL,k ) ) * b1; xmm5 += set( A(i ,k+1UL) ) * b2; xmm6 += set( A(i+1UL,k+1UL) ) * b2; xmm7 += set( A(i+2UL,k+1UL) ) * b2; xmm8 += set( A(i+3UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; xmm4 += set( A(i+3UL,k) ) * b1; } (~C).store( i , j, (~C).load(i ,j) + (xmm1+xmm5) * factor ); (~C).store( i+1UL, j, (~C).load(i+1UL,j) + (xmm2+xmm6) * factor ); (~C).store( i+2UL, j, (~C).load(i+2UL,j) + (xmm3+xmm7) * factor ); (~C).store( i+3UL, j, (~C).load(i+3UL,j) + (xmm4+xmm8) * factor ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i ,k+1UL) ) * b2; xmm5 += set( A(i+1UL,k+1UL) ) * b2; xmm6 += set( A(i+2UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; } (~C).store( i , j, (~C).load(i ,j) + (xmm1+xmm4) * factor ); (~C).store( i+1UL, j, (~C).load(i+1UL,j) + (xmm2+xmm5) * factor ); (~C).store( i+2UL, j, (~C).load(i+2UL,j) + (xmm3+xmm6) * factor ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i ,k+1UL) ) * b2; xmm4 += set( A(i+1UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; } (~C).store( i , j, (~C).load(i ,j) + (xmm1+xmm3) * factor ); (~C).store( i+1UL, j, (~C).load(i+1UL,j) + (xmm2+xmm4) * factor ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); SIMDType xmm1, xmm2; size_t k( kbegin ); for( ; (k+2UL) <= K; k+=2UL ) { xmm1 += set( A(i,k ) ) * B.load(k ,j); xmm2 += set( A(i,k+1UL) ) * B.load(k+1UL,j); } for( ; k<K; ++k ) { xmm1 += set( A(i,k) ) * B.load(k,j); } (~C).store( i, j, (~C).load(i,j) + (xmm1+xmm2) * factor ); } } for( ; remainder && j<N; ++j ) { const size_t iend( UPP ? j+1UL : M ); size_t i( LOW ? j : 0UL ); for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); ElementType value1 = ElementType(); ElementType value2 = ElementType(); for( size_t k=kbegin; k<kend; ++k ) { value1 += A(i ,k) * B(k,j); value2 += A(i+1UL,k) * B(k,j); } (~C)(i ,j) += value1 * scalar; (~C)(i+1UL,j) += value2 * scalar; } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); ElementType value = ElementType(); for( size_t k=kbegin; k<K; ++k ) { value += A(i,k) * B(k,j); } (~C)(i,j) += value * scalar; } } } //********************************************************************************************** //**Vectorized default addition assignment to column-major dense matrices (small matrices)****** /*!\brief Vectorized default addition assignment of a small scaled dense matrix-dense matrix // multiplication (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default addition assignment of a scaled dense // matrix-dense matrix multiplication expression to a column-major dense matrix. This // kernel is optimized for small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallAddAssignKernel( DenseMatrix<MT3,true>& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT4 ); BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT5 ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT4> ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT5> ); const ForwardFunctor fwd; if( !IsResizable<MT4>::value && IsResizable<MT5>::value ) { const OppositeType_<MT4> tmp( serial( A ) ); addAssign( ~C, fwd( tmp * B ) * scalar ); } else if( IsResizable<MT4>::value && !IsResizable<MT5>::value ) { const OppositeType_<MT5> tmp( serial( B ) ); addAssign( ~C, fwd( A * tmp ) * scalar ); } else if( A.rows() * A.columns() <= B.rows() * B.columns() ) { const OppositeType_<MT4> tmp( serial( A ) ); addAssign( ~C, fwd( tmp * B ) * scalar ); } else { const OppositeType_<MT5> tmp( serial( B ) ); addAssign( ~C, fwd( A * tmp ) * scalar ); } } //********************************************************************************************** //**Default addition assignment to dense matrices (large matrices)****************************** /*!\brief Default addition assignment of a large scaled dense matrix-dense matrix multiplication // (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the addition assignment of a scaled // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectDefaultAddAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Vectorized default addition assignment to dense matrices (large matrices)******************* /*!\brief Vectorized default addition assignment of a large scaled dense matrix-dense matrix // multiplication (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default addition assignment of a scaled dense // matrix-dense matrix multiplication expression to a dense matrix. This kernel is optimized // for large matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectLargeAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { if( LOW ) lmmm( C, A, B, scalar, ST2(1) ); else if( UPP ) ummm( C, A, B, scalar, ST2(1) ); else mmm( C, A, B, scalar, ST2(1) ); } //********************************************************************************************** //**BLAS-based addition assignment to dense matrices (default)********************************** /*!\brief Default addition assignment of a scaled dense matrix-dense matrix multiplication // (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the addition assignment of a large // scaled dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseBlasKernel<MT3,MT4,MT5,ST2> > selectBlasAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectLargeAddAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**BLAS-based addition assignment to dense matrices******************************************** #if BLAZE_BLAS_MODE && BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION /*!\brief BLAS-based addition assignment of a scaled dense matrix-dense matrix multiplication // (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function performs the scaled dense matrix-dense matrix multiplication based on the // according BLAS functionality. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseBlasKernel<MT3,MT4,MT5,ST2> > selectBlasAddAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { using ET = ElementType_<MT3>; if( IsTriangular<MT4>::value ) { ResultType_<MT3> tmp( serial( B ) ); trmm( tmp, A, CblasLeft, ( IsLower<MT4>::value )?( CblasLower ):( CblasUpper ), ET(scalar) ); addAssign( C, tmp ); } else if( IsTriangular<MT5>::value ) { ResultType_<MT3> tmp( serial( A ) ); trmm( tmp, B, CblasRight, ( IsLower<MT5>::value )?( CblasLower ):( CblasUpper ), ET(scalar) ); addAssign( C, tmp ); } else { gemm( C, A, B, ET(scalar), ET(1) ); } } #endif //********************************************************************************************** //**Restructuring addition assignment to column-major matrices********************************** /*!\brief Restructuring addition assignment of a scaled dense matrix-dense matrix multiplication // to a column-major matrix (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side scaled multiplication expression to be added. // \return void // // This function implements the symmetry-based restructuring addition assignment of a scaled // dense matrix-dense matrix multiplication expression to a column-major matrix. Due to the // explicit application of the SFINAE principle this function can only be selected by the // compiler in case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > addAssign( Matrix<MT,true>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) addAssign( ~lhs, fwd( trans( left ) * trans( right ) ) * rhs.scalar_ ); else if( IsSymmetric<MT1>::value ) addAssign( ~lhs, fwd( trans( left ) * right ) * rhs.scalar_ ); else addAssign( ~lhs, fwd( left * trans( right ) ) * rhs.scalar_ ); } //********************************************************************************************** //**Addition assignment to sparse matrices****************************************************** // No special implementation for the addition assignment to sparse matrices. //********************************************************************************************** //**Subtraction assignment to dense matrices**************************************************** /*!\brief Subtraction assignment of a scaled dense matrix-dense matrix multiplication to a // dense matrix (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side scaled multiplication expression to be subtracted. // \return void // // This function implements the performance optimized subtraction assignment of a scaled dense // matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline DisableIf_< CanExploitSymmetry<MT,MT1,MT2> > subAssign( DenseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL || left.columns() == 0UL ) { return; } LT A( serial( left ) ); // Evaluation of the left-hand side dense matrix operand RT B( serial( right ) ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == left.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == left.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == right.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == right.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns(), "Invalid number of columns" ); DMatScalarMultExpr::selectSubAssignKernel( ~lhs, A, B, rhs.scalar_ ); } //********************************************************************************************** //**Subtraction assignment to dense matrices (kernel selection)********************************* /*!\brief Selection of the kernel for a subtraction assignment of a scaled dense matrix-dense // matrix multiplication to a dense matrix (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline void selectSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { if( ( IsDiagonal<MT5>::value ) || ( !BLAZE_DEBUG_MODE && B.columns() <= SIMDSIZE*10UL ) || ( C.rows() * C.columns() < DMATDMATMULT_THRESHOLD ) ) selectSmallSubAssignKernel( C, A, B, scalar ); else selectBlasSubAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Default subtraction assignment to dense matrices (general/general)************************** /*!\brief Default subtraction assignment of a scaled general dense matrix-general dense matrix // multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default subtraction assignment of a scaled general dense // matrix-general dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< Not< IsDiagonal<MT4> >, Not< IsDiagonal<MT5> > > > selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { const ResultType tmp( serial( A * B * scalar ) ); subAssign( C, tmp ); } //********************************************************************************************** //**Default subtraction assignment to dense matrices (general/diagonal)************************* /*!\brief Default subtraction assignment of a scaled general dense matrix-diagonal dense matrix // multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default subtraction assignment of a scaled general dense // matrix-diagonal dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< Not< IsDiagonal<MT4> >, IsDiagonal<MT5> > > selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT4>::value ) ?( IsStrictlyUpper<MT4>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) -= A(i,j ) * B(j ,j ) * scalar; C(i,j+1UL) -= A(i,j+1UL) * B(j+1UL,j+1UL) * scalar; } if( jpos < jend ) { C(i,jpos) -= A(i,jpos) * B(jpos,jpos) * scalar; } } } //********************************************************************************************** //**Default subtraction assignment to dense matrices (diagonal/general)************************* /*!\brief Default subtraction assignment of a scaled diagonal dense matrix-general dense matrix // multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default subtraction assignment of a scaled diagonal dense // matrix-general dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< IsDiagonal<MT4>, Not< IsDiagonal<MT5> > > > selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); const size_t M( A.rows() ); const size_t N( B.columns() ); for( size_t i=0UL; i<M; ++i ) { const size_t jbegin( ( IsUpper<MT5>::value ) ?( IsStrictlyUpper<MT5>::value ? i+1UL : i ) :( 0UL ) ); const size_t jend( ( IsLower<MT5>::value ) ?( IsStrictlyLower<MT5>::value ? i : i+1UL ) :( N ) ); BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" ); const size_t jnum( jend - jbegin ); const size_t jpos( jbegin + ( jnum & size_t(-2) ) ); for( size_t j=jbegin; j<jpos; j+=2UL ) { C(i,j ) -= A(i,i) * B(i,j ) * scalar; C(i,j+1UL) -= A(i,i) * B(i,j+1UL) * scalar; } if( jpos < jend ) { C(i,jpos) -= A(i,i) * B(i,jpos) * scalar; } } } //********************************************************************************************** //**Default subtraction assignment to dense matrices (diagonal/diagonal)************************ /*!\brief Default subtraction assignment of a scaled diagonal dense matrix-diagonal dense // matrix multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the default subtraction assignment of a scaled diagonal dense // matrix-diagonal dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< And< IsDiagonal<MT4>, IsDiagonal<MT5> > > selectDefaultSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT3 ); for( size_t i=0UL; i<A.rows(); ++i ) { C(i,i) -= A(i,i) * B(i,i) * scalar; } } //********************************************************************************************** //**Default subtraction assignment to dense matrices (small matrices)*************************** /*!\brief Default subtraction assignment of a small scaled dense matrix-dense matrix // multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the subtraction assignment of a scaled // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectDefaultSubAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Vectorized default subtraction assignment to row-major dense matrices (small matrices)****** /*!\brief Vectorized default subtraction assignment of a small scaled dense matrix-dense matrix // multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default subtraction assignment of a scaled dense // matrix-dense matrix multiplication expression to a row-major dense matrix. This kernel is // optimized for small matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallSubAssignKernel( DenseMatrix<MT3,false>& C, const MT4& A, const MT5& B, ST2 scalar ) { constexpr bool remainder( !IsPadded<MT3>::value || !IsPadded<MT5>::value ); const size_t M( A.rows() ); const size_t N( B.columns() ); const size_t K( A.columns() ); BLAZE_INTERNAL_ASSERT( !( LOW || UPP ) || ( M == N ), "Broken invariant detected" ); const size_t jpos( remainder ? ( N & size_t(-SIMDSIZE) ) : N ); BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % SIMDSIZE ) ) == jpos, "Invalid end calculation" ); const SIMDType factor( set( scalar ) ); size_t j( 0UL ); if( IsIntegral<ElementType>::value ) { for( ; !LOW && !UPP && (j+SIMDSIZE*7UL) < jpos; j+=SIMDSIZE*8UL ) { for( size_t i=0UL; i<M; ++i ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i : i+1UL ), j+SIMDSIZE*8UL, K ) ) :( IsStrictlyLower<MT4>::value ? i : i+1UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*8UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); xmm6 += a1 * B.load(k,j+SIMDSIZE*5UL); xmm7 += a1 * B.load(k,j+SIMDSIZE*6UL); xmm8 += a1 * B.load(k,j+SIMDSIZE*7UL); } (~C).store( i, j , (~C).load(i,j ) - xmm1 * factor ); (~C).store( i, j+SIMDSIZE , (~C).load(i,j+SIMDSIZE ) - xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, (~C).load(i,j+SIMDSIZE*2UL) - xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, (~C).load(i,j+SIMDSIZE*3UL) - xmm4 * factor ); (~C).store( i, j+SIMDSIZE*4UL, (~C).load(i,j+SIMDSIZE*4UL) - xmm5 * factor ); (~C).store( i, j+SIMDSIZE*5UL, (~C).load(i,j+SIMDSIZE*5UL) - xmm6 * factor ); (~C).store( i, j+SIMDSIZE*6UL, (~C).load(i,j+SIMDSIZE*6UL) - xmm7 * factor ); (~C).store( i, j+SIMDSIZE*7UL, (~C).load(i,j+SIMDSIZE*7UL) - xmm8 * factor ); } } } for( ; !LOW && !UPP && (j+SIMDSIZE*4UL) < jpos; j+=SIMDSIZE*5UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*5UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*5UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); const SIMDType b5( B.load(k,j+SIMDSIZE*4UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a1 * b5; xmm6 += a2 * b1; xmm7 += a2 * b2; xmm8 += a2 * b3; xmm9 += a2 * b4; xmm10 += a2 * b5; } (~C).store( i , j , (~C).load(i ,j ) - xmm1 * factor ); (~C).store( i , j+SIMDSIZE , (~C).load(i ,j+SIMDSIZE ) - xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, (~C).load(i ,j+SIMDSIZE*2UL) - xmm3 * factor ); (~C).store( i , j+SIMDSIZE*3UL, (~C).load(i ,j+SIMDSIZE*3UL) - xmm4 * factor ); (~C).store( i , j+SIMDSIZE*4UL, (~C).load(i ,j+SIMDSIZE*4UL) - xmm5 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) - xmm6 * factor ); (~C).store( i+1UL, j+SIMDSIZE , (~C).load(i+1UL,j+SIMDSIZE ) - xmm7 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, (~C).load(i+1UL,j+SIMDSIZE*2UL) - xmm8 * factor ); (~C).store( i+1UL, j+SIMDSIZE*3UL, (~C).load(i+1UL,j+SIMDSIZE*3UL) - xmm9 * factor ); (~C).store( i+1UL, j+SIMDSIZE*4UL, (~C).load(i+1UL,j+SIMDSIZE*4UL) - xmm10 * factor ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*5UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); xmm5 += a1 * B.load(k,j+SIMDSIZE*4UL); } (~C).store( i, j , (~C).load(i,j ) - xmm1 * factor ); (~C).store( i, j+SIMDSIZE , (~C).load(i,j+SIMDSIZE ) - xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, (~C).load(i,j+SIMDSIZE*2UL) - xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, (~C).load(i,j+SIMDSIZE*3UL) - xmm4 * factor ); (~C).store( i, j+SIMDSIZE*4UL, (~C).load(i,j+SIMDSIZE*4UL) - xmm5 * factor ); } } for( ; !LOW && !UPP && (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*4UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*4UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); const SIMDType b4( B.load(k,j+SIMDSIZE*3UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a1 * b4; xmm5 += a2 * b1; xmm6 += a2 * b2; xmm7 += a2 * b3; xmm8 += a2 * b4; } (~C).store( i , j , (~C).load(i ,j ) - xmm1 * factor ); (~C).store( i , j+SIMDSIZE , (~C).load(i ,j+SIMDSIZE ) - xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, (~C).load(i ,j+SIMDSIZE*2UL) - xmm3 * factor ); (~C).store( i , j+SIMDSIZE*3UL, (~C).load(i ,j+SIMDSIZE*3UL) - xmm4 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) - xmm5 * factor ); (~C).store( i+1UL, j+SIMDSIZE , (~C).load(i+1UL,j+SIMDSIZE ) - xmm6 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, (~C).load(i+1UL,j+SIMDSIZE*2UL) - xmm7 * factor ); (~C).store( i+1UL, j+SIMDSIZE*3UL, (~C).load(i+1UL,j+SIMDSIZE*3UL) - xmm8 * factor ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*4UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); xmm4 += a1 * B.load(k,j+SIMDSIZE*3UL); } (~C).store( i, j , (~C).load(i,j ) - xmm1 * factor ); (~C).store( i, j+SIMDSIZE , (~C).load(i,j+SIMDSIZE ) - xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, (~C).load(i,j+SIMDSIZE*2UL) - xmm3 * factor ); (~C).store( i, j+SIMDSIZE*3UL, (~C).load(i,j+SIMDSIZE*3UL) - xmm4 * factor ); } } for( ; !LOW && !UPP && (j+SIMDSIZE*2UL) < jpos; j+=SIMDSIZE*3UL ) { size_t i( 0UL ); for( ; (i+2UL) <= M; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*3UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*3UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE ) ); const SIMDType b3( B.load(k,j+SIMDSIZE*2UL) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a1 * b3; xmm4 += a2 * b1; xmm5 += a2 * b2; xmm6 += a2 * b3; } (~C).store( i , j , (~C).load(i ,j ) - xmm1 * factor ); (~C).store( i , j+SIMDSIZE , (~C).load(i ,j+SIMDSIZE ) - xmm2 * factor ); (~C).store( i , j+SIMDSIZE*2UL, (~C).load(i ,j+SIMDSIZE*2UL) - xmm3 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) - xmm4 * factor ); (~C).store( i+1UL, j+SIMDSIZE , (~C).load(i+1UL,j+SIMDSIZE ) - xmm5 * factor ); (~C).store( i+1UL, j+SIMDSIZE*2UL, (~C).load(i+1UL,j+SIMDSIZE*2UL) - xmm6 * factor ); } if( i < M ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*3UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE ); xmm3 += a1 * B.load(k,j+SIMDSIZE*2UL); } (~C).store( i, j , (~C).load(i,j ) - xmm1 * factor ); (~C).store( i, j+SIMDSIZE , (~C).load(i,j+SIMDSIZE ) - xmm2 * factor ); (~C).store( i, j+SIMDSIZE*2UL, (~C).load(i,j+SIMDSIZE*2UL) - xmm3 * factor ); } } for( ; !( LOW && UPP ) && (j+SIMDSIZE) < jpos; j+=SIMDSIZE*2UL ) { const size_t iend( UPP ? min(j+SIMDSIZE*2UL,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType a4( set( A(i+3UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; xmm7 += a4 * b1; xmm8 += a4 * b2; } (~C).store( i , j , (~C).load(i ,j ) - xmm1 * factor ); (~C).store( i , j+SIMDSIZE, (~C).load(i ,j+SIMDSIZE) - xmm2 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) - xmm3 * factor ); (~C).store( i+1UL, j+SIMDSIZE, (~C).load(i+1UL,j+SIMDSIZE) - xmm4 * factor ); (~C).store( i+2UL, j , (~C).load(i+2UL,j ) - xmm5 * factor ); (~C).store( i+2UL, j+SIMDSIZE, (~C).load(i+2UL,j+SIMDSIZE) - xmm6 * factor ); (~C).store( i+3UL, j , (~C).load(i+3UL,j ) - xmm7 * factor ); (~C).store( i+3UL, j+SIMDSIZE, (~C).load(i+3UL,j+SIMDSIZE) - xmm8 * factor ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; for( size_t k=kbegin; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType a3( set( A(i+2UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b1; xmm6 += a3 * b2; } (~C).store( i , j , (~C).load(i ,j ) - xmm1 * factor ); (~C).store( i , j+SIMDSIZE, (~C).load(i ,j+SIMDSIZE) - xmm2 * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) - xmm3 * factor ); (~C).store( i+1UL, j+SIMDSIZE, (~C).load(i+1UL,j+SIMDSIZE) - xmm4 * factor ); (~C).store( i+2UL, j , (~C).load(i+2UL,j ) - xmm5 * factor ); (~C).store( i+2UL, j+SIMDSIZE, (~C).load(i+2UL,j+SIMDSIZE) - xmm6 * factor ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( ( IsUpper<MT5>::value ) ?( min( ( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ), j+SIMDSIZE*2UL, K ) ) :( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) ) :( IsUpper<MT5>::value ? min( j+SIMDSIZE*2UL, K ) : K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i ,k ) ) ); const SIMDType a2( set( A(i+1UL,k ) ) ); const SIMDType a3( set( A(i ,k+1UL) ) ); const SIMDType a4( set( A(i+1UL,k+1UL) ) ); const SIMDType b1( B.load(k ,j ) ); const SIMDType b2( B.load(k ,j+SIMDSIZE) ); const SIMDType b3( B.load(k+1UL,j ) ); const SIMDType b4( B.load(k+1UL,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; xmm5 += a3 * b3; xmm6 += a3 * b4; xmm7 += a4 * b3; xmm8 += a4 * b4; } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i ,k) ) ); const SIMDType a2( set( A(i+1UL,k) ) ); const SIMDType b1( B.load(k,j ) ); const SIMDType b2( B.load(k,j+SIMDSIZE) ); xmm1 += a1 * b1; xmm2 += a1 * b2; xmm3 += a2 * b1; xmm4 += a2 * b2; } (~C).store( i , j , (~C).load(i ,j ) - (xmm1+xmm5) * factor ); (~C).store( i , j+SIMDSIZE, (~C).load(i ,j+SIMDSIZE) - (xmm2+xmm6) * factor ); (~C).store( i+1UL, j , (~C).load(i+1UL,j ) - (xmm3+xmm7) * factor ); (~C).store( i+1UL, j+SIMDSIZE, (~C).load(i+1UL,j+SIMDSIZE) - (xmm4+xmm8) * factor ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsUpper<MT5>::value )?( min( j+SIMDSIZE*2UL, K ) ):( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType a1( set( A(i,k ) ) ); const SIMDType a2( set( A(i,k+1UL) ) ); xmm1 += a1 * B.load(k ,j ); xmm2 += a1 * B.load(k ,j+SIMDSIZE); xmm3 += a2 * B.load(k+1UL,j ); xmm4 += a2 * B.load(k+1UL,j+SIMDSIZE); } for( ; k<kend; ++k ) { const SIMDType a1( set( A(i,k) ) ); xmm1 += a1 * B.load(k,j ); xmm2 += a1 * B.load(k,j+SIMDSIZE); } (~C).store( i, j , (~C).load(i,j ) - (xmm1+xmm3) * factor ); (~C).store( i, j+SIMDSIZE, (~C).load(i,j+SIMDSIZE) - (xmm2+xmm4) * factor ); } } for( ; j<jpos; j+=SIMDSIZE ) { const size_t iend( LOW && UPP ? min(j+SIMDSIZE,M) : M ); size_t i( LOW ? j : 0UL ); for( ; (i+4UL) <= iend; i+=4UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+3UL : i+4UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i+3UL,k ) ) * b1; xmm5 += set( A(i ,k+1UL) ) * b2; xmm6 += set( A(i+1UL,k+1UL) ) * b2; xmm7 += set( A(i+2UL,k+1UL) ) * b2; xmm8 += set( A(i+3UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; xmm4 += set( A(i+3UL,k) ) * b1; } (~C).store( i , j, (~C).load(i ,j) - (xmm1+xmm5) * factor ); (~C).store( i+1UL, j, (~C).load(i+1UL,j) - (xmm2+xmm6) * factor ); (~C).store( i+2UL, j, (~C).load(i+2UL,j) - (xmm3+xmm7) * factor ); (~C).store( i+3UL, j, (~C).load(i+3UL,j) - (xmm4+xmm8) * factor ); } for( ; (i+3UL) <= iend; i+=3UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+2UL : i+3UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4, xmm5, xmm6; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i+2UL,k ) ) * b1; xmm4 += set( A(i ,k+1UL) ) * b2; xmm5 += set( A(i+1UL,k+1UL) ) * b2; xmm6 += set( A(i+2UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; xmm3 += set( A(i+2UL,k) ) * b1; } (~C).store( i , j, (~C).load(i ,j) - (xmm1+xmm4) * factor ); (~C).store( i+1UL, j, (~C).load(i+1UL,j) - (xmm2+xmm5) * factor ); (~C).store( i+2UL, j, (~C).load(i+2UL,j) - (xmm3+xmm6) * factor ); } for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); SIMDType xmm1, xmm2, xmm3, xmm4; size_t k( kbegin ); for( ; (k+2UL) <= kend; k+=2UL ) { const SIMDType b1( B.load(k ,j) ); const SIMDType b2( B.load(k+1UL,j) ); xmm1 += set( A(i ,k ) ) * b1; xmm2 += set( A(i+1UL,k ) ) * b1; xmm3 += set( A(i ,k+1UL) ) * b2; xmm4 += set( A(i+1UL,k+1UL) ) * b2; } for( ; k<kend; ++k ) { const SIMDType b1( B.load(k,j) ); xmm1 += set( A(i ,k) ) * b1; xmm2 += set( A(i+1UL,k) ) * b1; } (~C).store( i , j, (~C).load(i ,j) - (xmm1+xmm3) * factor ); (~C).store( i+1UL, j, (~C).load(i+1UL,j) - (xmm2+xmm4) * factor ); } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); SIMDType xmm1, xmm2; size_t k( kbegin ); for( ; (k+2UL) <= K; k+=2UL ) { xmm1 += set( A(i,k ) ) * B.load(k ,j); xmm2 += set( A(i,k+1UL) ) * B.load(k+1UL,j); } for( ; k<K; ++k ) { xmm1 += set( A(i,k) ) * B.load(k,j); } (~C).store( i, j, (~C).load(i,j) - (xmm1+xmm2) * factor ); } } for( ; remainder && j<N; ++j ) { const size_t iend( UPP ? j+1UL : M ); size_t i( LOW ? j : 0UL ); for( ; (i+2UL) <= iend; i+=2UL ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); const size_t kend( ( IsLower<MT4>::value ) ?( IsStrictlyLower<MT4>::value ? i+1UL : i+2UL ) :( K ) ); ElementType value1 = ElementType(); ElementType value2 = ElementType(); for( size_t k=kbegin; k<kend; ++k ) { value1 += A(i ,k) * B(k,j); value2 += A(i+1UL,k) * B(k,j); } (~C)(i ,j) -= value1 * scalar; (~C)(i+1UL,j) -= value2 * scalar; } if( i < iend ) { const size_t kbegin( ( IsUpper<MT4>::value ) ?( ( IsLower<MT5>::value ) ?( max( ( IsStrictlyUpper<MT4>::value ? i+1UL : i ), j ) ) :( IsStrictlyUpper<MT4>::value ? i+1UL : i ) ) :( IsLower<MT5>::value ? j : 0UL ) ); ElementType value = ElementType(); for( size_t k=kbegin; k<K; ++k ) { value += A(i,k) * B(k,j); } (~C)(i,j) -= value * scalar; } } } //********************************************************************************************** //**Vectorized default subtraction assignment to column-major dense matrices (small matrices)*** /*!\brief Vectorized default subtraction assignment of a small scaled dense matrix-dense matrix // multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default subtraction assignment of a small scaled // dense matrix-dense matrix multiplication expression to a column-major dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectSmallSubAssignKernel( DenseMatrix<MT3,true>& C, const MT4& A, const MT5& B, ST2 scalar ) { BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT4 ); BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT5 ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT4> ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType_<MT5> ); const ForwardFunctor fwd; if( !IsResizable<MT4>::value && IsResizable<MT5>::value ) { const OppositeType_<MT4> tmp( serial( A ) ); subAssign( ~C, fwd( tmp * B ) * scalar ); } else if( IsResizable<MT4>::value && !IsResizable<MT5>::value ) { const OppositeType_<MT5> tmp( serial( B ) ); subAssign( ~C, fwd( A * tmp ) * scalar ); } else if( A.rows() * A.columns() <= B.rows() * B.columns() ) { const OppositeType_<MT4> tmp( serial( A ) ); subAssign( ~C, fwd( tmp * B ) * scalar ); } else { const OppositeType_<MT5> tmp( serial( B ) ); subAssign( ~C, fwd( A * tmp ) * scalar ); } } //********************************************************************************************** //**Default subtraction assignment to dense matrices (large matrices)*************************** /*!\brief Default subtraction assignment of a large scaled dense matrix-dense matrix // multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the subtraction assignment of a scaled // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectDefaultSubAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**Vectorized default subtraction assignment to dense matrices (large matrices)**************** /*!\brief Vectorized default subtraction assignment of a large scaled dense matrix-dense matrix // multiplication (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function implements the vectorized default subtraction assignment of a scaled dense // matrix-dense matrix multiplication expression to a dense matrix. This kernel is optimized // for large matrices. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseVectorizedDefaultKernel<MT3,MT4,MT5,ST2> > selectLargeSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { if( LOW ) lmmm( C, A, B, -scalar, ST2(1) ); else if( UPP ) ummm( C, A, B, -scalar, ST2(1) ); else mmm( C, A, B, -scalar, ST2(1) ); } //********************************************************************************************** //**BLAS-based subtraction assignment to dense matrices (default)******************************* /*!\brief Default subtraction assignment of a scaled dense matrix-dense matrix multiplication // (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function relays to the default implementation of the subtraction assignment of a large // scaled dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline DisableIf_< UseBlasKernel<MT3,MT4,MT5,ST2> > selectBlasSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { selectLargeSubAssignKernel( C, A, B, scalar ); } //********************************************************************************************** //**BLAS-based subraction assignment to dense matrices****************************************** #if BLAZE_BLAS_MODE && BLAZE_USE_BLAS_MATRIX_MATRIX_MULTIPLICATION /*!\brief BLAS-based subraction assignment of a scaled dense matrix-dense matrix multiplication // (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param C The target left-hand side dense matrix. // \param A The left-hand side multiplication operand. // \param B The right-hand side multiplication operand. // \param scalar The scaling factor. // \return void // // This function performs the scaled dense matrix-dense matrix multiplication based on the // according BLAS functionality. */ template< typename MT3 // Type of the left-hand side target matrix , typename MT4 // Type of the left-hand side matrix operand , typename MT5 // Type of the right-hand side matrix operand , typename ST2 > // Type of the scalar value static inline EnableIf_< UseBlasKernel<MT3,MT4,MT5,ST2> > selectBlasSubAssignKernel( MT3& C, const MT4& A, const MT5& B, ST2 scalar ) { using ET = ElementType_<MT3>; if( IsTriangular<MT4>::value ) { ResultType_<MT3> tmp( serial( B ) ); trmm( tmp, A, CblasLeft, ( IsLower<MT4>::value )?( CblasLower ):( CblasUpper ), ET(scalar) ); subAssign( C, tmp ); } else if( IsTriangular<MT5>::value ) { ResultType_<MT3> tmp( serial( A ) ); trmm( tmp, B, CblasRight, ( IsLower<MT5>::value )?( CblasLower ):( CblasUpper ), ET(scalar) ); subAssign( C, tmp ); } else { gemm( C, A, B, ET(-scalar), ET(1) ); } } #endif //********************************************************************************************** //**Restructuring subtraction assignment to column-major matrices******************************* /*!\brief Restructuring subtraction assignment of a scaled dense matrix-dense matrix // multiplication to a column-major matrix (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side scaled multiplication expression to be subtracted. // \return void // // This function implements the symmetry-based restructuring subtraction assignment of a scaled // dense matrix-dense matrix multiplication expression to a column-major matrix. Due to the // explicit application of the SFINAE principle this function can only be selected by the // compiler in case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > subAssign( Matrix<MT,true>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) subAssign( ~lhs, fwd( trans( left ) * trans( right ) ) * rhs.scalar_ ); else if( IsSymmetric<MT1>::value ) subAssign( ~lhs, fwd( trans( left ) * right ) * rhs.scalar_ ); else subAssign( ~lhs, fwd( left * trans( right ) ) * rhs.scalar_ ); } //********************************************************************************************** //**Subtraction assignment to sparse matrices*************************************************** // No special implementation for the subtraction assignment to sparse matrices. //********************************************************************************************** //**Schur product assignment to dense matrices************************************************** /*!\brief Schur product assignment of a scaled dense matrix-dense matrix multiplication to a // dense matrix (\f$ C\circ=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side scaled multiplication expression for the Schur product. // \return void // // This function implements the performance optimized Schur product assignment of a scaled // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline void schurAssign( DenseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ResultType tmp( serial( rhs ) ); schurAssign( ~lhs, tmp ); } //********************************************************************************************** //**Schur product assignment to sparse matrices************************************************* // No special implementation for the Schur product assignment to sparse matrices. //********************************************************************************************** //**Multiplication assignment to dense matrices************************************************* // No special implementation for the multiplication assignment to dense matrices. //********************************************************************************************** //**Multiplication assignment to sparse matrices************************************************ // No special implementation for the multiplication assignment to sparse matrices. //********************************************************************************************** //**SMP assignment to dense matrices************************************************************ /*!\brief SMP assignment of a scaled dense matrix-dense matrix multiplication to a dense matrix // (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side scaled multiplication expression to be assigned. // \return void // // This function implements the performance optimized assignment of a scaled dense matrix- // dense matrix multiplication expression to a dense matrix. Due to the explicit application // of the SFINAE principle this function can only be selected by the compiler in case either // of the two matrix operands requires an intermediate evaluation and no symmetry can be // exploited. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> > smpAssign( DenseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL ) { return; } else if( left.columns() == 0UL ) { reset( ~lhs ); return; } LT A( left ); // Evaluation of the left-hand side dense matrix operand RT B( right ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == left.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == left.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == right.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == right.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns(), "Invalid number of columns" ); smpAssign( ~lhs, A * B * rhs.scalar_ ); } //********************************************************************************************** //**SMP assignment to sparse matrices*********************************************************** /*!\brief SMP assignment of a scaled dense matrix-dense matrix multiplication to a sparse matrix // (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side sparse matrix. // \param rhs The right-hand side scaled multiplication expression to be assigned. // \return void // // This function implements the performance optimized SMP assignment of a scaled dense matrix- // dense matrix multiplication expression to a sparse matrix. Due to the explicit application // of the SFINAE principle this function can only be selected by the compiler in case either // of the two matrix operands requires an intermediate evaluation and no symmetry can be // exploited. */ template< typename MT // Type of the target sparse matrix , bool SO > // Storage order of the target sparse matrix friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> > smpAssign( SparseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; using TmpType = IfTrue_< SO, OppositeType, ResultType >; BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( OppositeType ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE( OppositeType ); BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER( MT, TmpType ); BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( TmpType ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; const TmpType tmp( rhs ); smpAssign( ~lhs, fwd( tmp ) ); } //********************************************************************************************** //**Restructuring SMP assignment to column-major matrices*************************************** /*!\brief Restructuring SMP assignment of a scaled dense matrix-dense matrix multiplication to // a column-major matrix (\f$ C=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side scaled multiplication expression to be assigned. // \return void // // This function implements the symmetry-based restructuring SMP assignment of a scaled dense // matrix-dense matrix multiplication expression to a column-major matrix. Due to the // explicit application of the SFINAE principle this function can only be selected by // the compiler in case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > smpAssign( Matrix<MT,true>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) smpAssign( ~lhs, fwd( trans( left ) * trans( right ) ) * rhs.scalar_ ); else if( IsSymmetric<MT1>::value ) smpAssign( ~lhs, fwd( trans( left ) * right ) * rhs.scalar_ ); else smpAssign( ~lhs, fwd( left * trans( right ) ) * rhs.scalar_ ); } //********************************************************************************************** //**SMP addition assignment to dense matrices*************************************************** /*!\brief SMP addition assignment of a scaled dense matrix-dense matrix multiplication to a // dense matrix (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side scaled multiplication expression to be added. // \return void // // This function implements the performance optimized addition assignment of a scaled dense // matrix-dense matrix multiplication expression to a dense matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler // in case either of the two matrix operands requires an intermediate evaluation and no // symmetry can be exploited. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> > smpAddAssign( DenseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL || left.columns() == 0UL ) { return; } LT A( left ); // Evaluation of the left-hand side dense matrix operand RT B( right ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == left.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == left.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == right.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == right.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns(), "Invalid number of columns" ); smpAddAssign( ~lhs, A * B * rhs.scalar_ ); } //********************************************************************************************** //**Restructuring SMP addition assignment to column-major matrices****************************** /*!\brief Restructuring SMP addition assignment of a scaled dense matrix-dense matrix // multiplication to a column-major matrix (\f$ C+=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side scaled multiplication expression to be added. // \return void // // This function implements the symmetry-based restructuring SMP addition assignment of a scaled // dense matrix-dense matrix multiplication expression to a column-major matrix. Due to the // explicit application of the SFINAE principle this function can only be selected by the // compiler in case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > smpAddAssign( Matrix<MT,true>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) smpAddAssign( ~lhs, fwd( trans( left ) * trans( right ) ) * rhs.scalar_ ); else if( IsSymmetric<MT1>::value ) smpAddAssign( ~lhs, fwd( trans( left ) * right ) * rhs.scalar_ ); else smpAddAssign( ~lhs, fwd( left * trans( right ) ) * rhs.scalar_ ); } //********************************************************************************************** //**SMP addition assignment to sparse matrices************************************************** // No special implementation for the SMP addition assignment to sparse matrices. //********************************************************************************************** //**SMP subtraction assignment to dense matrices************************************************ /*!\brief SMP subtraction assignment of a scaled dense matrix-dense matrix multiplication to a // dense matrix (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side scaled multiplication expression to be subtracted. // \return void // // This function implements the performance optimized SMP subtraction assignment of a scaled // dense matrix-dense matrix multiplication expression to a dense matrix. Due to the explicit // application of the SFINAE principle this function can only be selected by the compiler // in case either of the two matrix operands requires an intermediate evaluation and no // symmetry can be exploited. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline EnableIf_< IsEvaluationRequired<MT,MT1,MT2> > smpSubAssign( DenseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( (~lhs).rows() == 0UL || (~lhs).columns() == 0UL || left.columns() == 0UL ) { return; } LT A( left ); // Evaluation of the left-hand side dense matrix operand RT B( right ); // Evaluation of the right-hand side dense matrix operand BLAZE_INTERNAL_ASSERT( A.rows() == left.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( A.columns() == left.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( B.rows() == right.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == right.columns() , "Invalid number of columns" ); BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns(), "Invalid number of columns" ); smpSubAssign( ~lhs, A * B * rhs.scalar_ ); } //********************************************************************************************** //**Restructuring SMP subtraction assignment to column-major matrices*************************** /*!\brief Restructuring SMP subtraction assignment of a scaled dense matrix-dense matrix // multiplication to a column-major matrix (\f$ C-=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side matrix. // \param rhs The right-hand side scaled multiplication expression to be subtracted. // \return void // // This function implements the symmetry-based restructuring SMP subtraction assignment of a // scaled dense matrix-dense matrix multiplication expression to a column-major matrix. Due // to the explicit application of the SFINAE principle this function can only be selected by // the compiler in case the symmetry of either of the two matrix operands can be exploited. */ template< typename MT > // Type of the target matrix friend inline EnableIf_< CanExploitSymmetry<MT,MT1,MT2> > smpSubAssign( Matrix<MT,true>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE( MT ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ForwardFunctor fwd; LeftOperand_<MMM> left ( rhs.matrix_.leftOperand() ); RightOperand_<MMM> right( rhs.matrix_.rightOperand() ); if( IsSymmetric<MT1>::value && IsSymmetric<MT2>::value ) smpSubAssign( ~lhs, fwd( trans( left ) * trans( right ) ) * rhs.scalar_ ); else if( IsSymmetric<MT1>::value ) smpSubAssign( ~lhs, fwd( trans( left ) * right ) * rhs.scalar_ ); else smpSubAssign( ~lhs, fwd( left * trans( right ) ) * rhs.scalar_ ); } //********************************************************************************************** //**SMP subtraction assignment to sparse matrices*********************************************** // No special implementation for the SMP subtraction assignment to sparse matrices. //********************************************************************************************** //**SMP Schur product assignment to dense matrices********************************************** /*!\brief SMP Schur product assignment of a scaled dense matrix-dense matrix multiplication to // a dense matrix (\f$ C\circ=s*A*B \f$). // \ingroup dense_matrix // // \param lhs The target left-hand side dense matrix. // \param rhs The right-hand side scaled multiplication expression for the Schur product. // \return void // // This function implements the performance optimized Schur product assignment of a scaled // dense matrix-dense matrix multiplication expression to a dense matrix. */ template< typename MT // Type of the target dense matrix , bool SO > // Storage order of the target dense matrix friend inline void smpSchurAssign( DenseMatrix<MT,SO>& lhs, const DMatScalarMultExpr& rhs ) { BLAZE_FUNCTION_TRACE; BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( ResultType ); BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( ResultType ); BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" ); BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" ); const ResultType tmp( rhs ); smpSchurAssign( ~lhs, tmp ); } //********************************************************************************************** //**SMP Schur product assignment to sparse matrices********************************************* // No special implementation for the SMP Schur product assignment to sparse matrices. //********************************************************************************************** //**SMP multiplication assignment to dense matrices********************************************* // No special implementation for the SMP multiplication assignment to dense matrices. //********************************************************************************************** //**SMP multiplication assignment to sparse matrices******************************************** // No special implementation for the SMP multiplication assignment to sparse matrices. //********************************************************************************************** //**Compile time checks************************************************************************* BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( MMM ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MMM ); BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( MT1 ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT1 ); BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( MT2 ); BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE( MT2 ); BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE( ST ); BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ST, RightOperand ); //********************************************************************************************** }; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // GLOBAL BINARY ARITHMETIC OPERATORS // //================================================================================================= //************************************************************************************************* /*!\brief Multiplication operator for the multiplication of two row-major dense matrices // (\f$ A=B*C \f$). // \ingroup dense_matrix // // \param lhs The left-hand side matrix for the multiplication. // \param rhs The right-hand side matrix for the multiplication. // \return The resulting matrix. // \exception std::invalid_argument Matrix sizes do not match. // // This operator represents the multiplication of two row-major dense matrices: \code using blaze::rowMajor; blaze::DynamicMatrix<double,rowMajor> A, B, C; // ... Resizing and initialization C = A * B; \endcode // The operator returns an expression representing a dense matrix of the higher-order element // type of the two involved matrix element types \a MT1::ElementType and \a MT2::ElementType. // Both matrix types \a MT1 and \a MT2 as well as the two element types \a MT1::ElementType // and \a MT2::ElementType have to be supported by the MultTrait class template.\n // In case the current number of columns of \a lhs and the current number of rows of \a rhs // don't match, a \a std::invalid_argument is thrown. */ template< typename MT1 // Type of the left-hand side dense matrix , typename MT2 > // Type of the right-hand side dense matrix inline decltype(auto) operator*( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,false>& rhs ) { BLAZE_FUNCTION_TRACE; if( (~lhs).columns() != (~rhs).rows() ) { BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" ); } using ReturnType = const DMatDMatMultExpr<MT1,MT2,false,false,false,false>; return ReturnType( ~lhs, ~rhs ); } //************************************************************************************************* //================================================================================================= // // GLOBAL FUNCTIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Declares the given non-symmetric matrix multiplication expression as symmetric. // \ingroup dense_matrix // // \param dm The input matrix multiplication expression. // \return The redeclared dense matrix multiplication expression. // \exception std::invalid_argument Invalid symmetric matrix specification. // // The \a declsym function declares the given non-symmetric matrix multiplication expression // \a dm as symmetric. The function returns an expression representing the operation. In case // the given expression does not represent a square matrix, a \a std::invalid_argument exception // is thrown.\n // The following example demonstrates the use of the \a declsym function: \code using blaze::rowMajor; blaze::DynamicMatrix<double,rowMajor> A, B, C; // ... Resizing and initialization C = declsym( A * B ); \endcode */ template< typename MT1 // Type of the left-hand side dense matrix , typename MT2 // Type of the right-hand side dense matrix , bool SF // Symmetry flag , bool HF // Hermitian flag , bool LF // Lower flag , bool UF > // Upper flag inline decltype(auto) declsym( const DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm ) { BLAZE_FUNCTION_TRACE; if( !isSquare( dm ) ) { BLAZE_THROW_INVALID_ARGUMENT( "Invalid symmetric matrix specification" ); } using ReturnType = const DMatDMatMultExpr<MT1,MT2,true,HF,LF,UF>; return ReturnType( dm.leftOperand(), dm.rightOperand() ); } /*! \endcond */ //************************************************************************************************* //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Declares the given non-Hermitian matrix multiplication expression as Hermitian. // \ingroup dense_matrix // // \param dm The input matrix multiplication expression. // \return The redeclared dense matrix multiplication expression. // \exception std::invalid_argument Invalid Hermitian matrix specification. // // The \a declherm function declares the given non-Hermitian matrix multiplication expression // \a dm as Hermitian. The function returns an expression representing the operation. In case // the given expression does not represent a square matrix, a \a std::invalid_argument exception // is thrown.\n // The following example demonstrates the use of the \a declherm function: \code using blaze::rowMajor; blaze::DynamicMatrix<double,rowMajor> A, B, C; // ... Resizing and initialization C = declherm( A * B ); \endcode */ template< typename MT1 // Type of the left-hand side dense matrix , typename MT2 // Type of the right-hand side dense matrix , bool SF // Symmetry flag , bool HF // Hermitian flag , bool LF // Lower flag , bool UF > // Upper flag inline decltype(auto) declherm( const DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm ) { BLAZE_FUNCTION_TRACE; if( !isSquare( dm ) ) { BLAZE_THROW_INVALID_ARGUMENT( "Invalid Hermitian matrix specification" ); } using ReturnType = const DMatDMatMultExpr<MT1,MT2,SF,true,LF,UF>; return ReturnType( dm.leftOperand(), dm.rightOperand() ); } /*! \endcond */ //************************************************************************************************* //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Declares the given non-lower matrix multiplication expression as lower. // \ingroup dense_matrix // // \param dm The input matrix multiplication expression. // \return The redeclared dense matrix multiplication expression. // \exception std::invalid_argument Invalid lower matrix specification. // // The \a decllow function declares the given non-lower matrix multiplication expression // \a dm as lower. The function returns an expression representing the operation. In case // the given expression does not represent a square matrix, a \a std::invalid_argument // exception is thrown.\n // The following example demonstrates the use of the \a decllow function: \code using blaze::rowMajor; blaze::DynamicMatrix<double,rowMajor> A, B, C; // ... Resizing and initialization C = decllow( A * B ); \endcode */ template< typename MT1 // Type of the left-hand side dense matrix , typename MT2 // Type of the right-hand side dense matrix , bool SF // Symmetry flag , bool HF // Hermitian flag , bool LF // Lower flag , bool UF > // Upper flag inline decltype(auto) decllow( const DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm ) { BLAZE_FUNCTION_TRACE; if( !isSquare( dm ) ) { BLAZE_THROW_INVALID_ARGUMENT( "Invalid lower matrix specification" ); } using ReturnType = const DMatDMatMultExpr<MT1,MT2,SF,HF,true,UF>; return ReturnType( dm.leftOperand(), dm.rightOperand() ); } /*! \endcond */ //************************************************************************************************* //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Declares the given non-upper matrix multiplication expression as upper. // \ingroup dense_matrix // // \param dm The input matrix multiplication expression. // \return The redeclared dense matrix multiplication expression. // \exception std::invalid_argument Invalid upper matrix specification. // // The \a declupp function declares the given non-upper matrix multiplication expression // \a dm as upper. The function returns an expression representing the operation. In case // the given expression does not represent a square matrix, a \a std::invalid_argument // exception is thrown.\n // The following example demonstrates the use of the \a declupp function: \code using blaze::rowMajor; blaze::DynamicMatrix<double,rowMajor> A, B, C; // ... Resizing and initialization C = declupp( A * B ); \endcode */ template< typename MT1 // Type of the left-hand side dense matrix , typename MT2 // Type of the right-hand side dense matrix , bool SF // Symmetry flag , bool HF // Hermitian flag , bool LF // Lower flag , bool UF > // Upper flag inline decltype(auto) declupp( const DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm ) { BLAZE_FUNCTION_TRACE; if( !isSquare( dm ) ) { BLAZE_THROW_INVALID_ARGUMENT( "Invalid upper matrix specification" ); } using ReturnType = const DMatDMatMultExpr<MT1,MT2,SF,HF,LF,true>; return ReturnType( dm.leftOperand(), dm.rightOperand() ); } /*! \endcond */ //************************************************************************************************* //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ /*!\brief Declares the given non-diagonal matrix multiplication expression as diagonal. // \ingroup dense_matrix // // \param dm The input matrix multiplication expression. // \return The redeclared dense matrix multiplication expression. // \exception std::invalid_argument Invalid diagonal matrix specification. // // The \a decldiag function declares the given non-diagonal matrix multiplication expression // \a dm as diagonal. The function returns an expression representing the operation. In case // the given expression does not represent a square matrix, a \a std::invalid_argument exception // is thrown.\n // The following example demonstrates the use of the \a decldiag function: \code using blaze::rowMajor; blaze::DynamicMatrix<double,rowMajor> A, B, C; // ... Resizing and initialization C = decldiag( A * B ); \endcode */ template< typename MT1 // Type of the left-hand side dense matrix , typename MT2 // Type of the right-hand side dense matrix , bool SF // Symmetry flag , bool HF // Hermitian flag , bool LF // Lower flag , bool UF > // Upper flag inline decltype(auto) decldiag( const DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF>& dm ) { BLAZE_FUNCTION_TRACE; if( !isSquare( dm ) ) { BLAZE_THROW_INVALID_ARGUMENT( "Invalid diagonal matrix specification" ); } using ReturnType = const DMatDMatMultExpr<MT1,MT2,SF,HF,true,true>; return ReturnType( dm.leftOperand(), dm.rightOperand() ); } /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ROWS SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct Rows< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public Rows<MT1> {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // COLUMNS SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct Columns< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public Columns<MT2> {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISALIGNED SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct IsAligned< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public BoolConstant< And< IsAligned<MT1>, IsAligned<MT2> >::value > {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISSYMMETRIC SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct IsSymmetric< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public BoolConstant< Or< Bool<SF> , And< Bool<HF> , IsBuiltin< ElementType_< DMatDMatMultExpr<MT1,MT2,false,true,false,false> > > > , And< Bool<LF>, Bool<UF> > >::value > {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISHERMITIAN SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool LF, bool UF > struct IsHermitian< DMatDMatMultExpr<MT1,MT2,SF,true,LF,UF> > : public TrueType {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISLOWER SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct IsLower< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public BoolConstant< Or< Bool<LF> , And< IsLower<MT1>, IsLower<MT2> > , And< Or< Bool<SF>, Bool<HF> > , IsUpper<MT1>, IsUpper<MT2> > >::value > {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISUNILOWER SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct IsUniLower< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public BoolConstant< Or< And< IsUniLower<MT1>, IsUniLower<MT2> > , And< Or< Bool<SF>, Bool<HF> > , IsUniUpper<MT1>, IsUniUpper<MT2> > >::value > {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISSTRICTLYLOWER SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct IsStrictlyLower< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public BoolConstant< Or< And< IsStrictlyLower<MT1>, IsLower<MT2> > , And< IsStrictlyLower<MT2>, IsLower<MT1> > , And< Or< Bool<SF>, Bool<HF> > , Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> > , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > > > >::value > {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISUPPER SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct IsUpper< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public BoolConstant< Or< Bool<UF> , And< IsUpper<MT1>, IsUpper<MT2> > , And< Or< Bool<SF>, Bool<HF> > , IsLower<MT1>, IsLower<MT2> > >::value > {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISUNIUPPER SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct IsUniUpper< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public BoolConstant< Or< And< IsUniUpper<MT1>, IsUniUpper<MT2> > , And< Or< Bool<SF>, Bool<HF> > , IsUniLower<MT1>, IsUniLower<MT2> > >::value > {}; /*! \endcond */ //************************************************************************************************* //================================================================================================= // // ISSTRICTLYUPPER SPECIALIZATIONS // //================================================================================================= //************************************************************************************************* /*! \cond BLAZE_INTERNAL */ template< typename MT1, typename MT2, bool SF, bool HF, bool LF, bool UF > struct IsStrictlyUpper< DMatDMatMultExpr<MT1,MT2,SF,HF,LF,UF> > : public BoolConstant< Or< And< IsStrictlyUpper<MT1>, IsUpper<MT2> > , And< IsStrictlyUpper<MT2>, IsUpper<MT1> > , And< Or< Bool<SF>, Bool<HF> > , Or< And< IsStrictlyLower<MT1>, IsLower<MT2> > , And< IsStrictlyLower<MT2>, IsLower<MT1> > > > >::value > {}; /*! \endcond */ //************************************************************************************************* } // namespace blaze #endif
Kolkir/blaze-nn
third-party/blaze/include/blaze/math/expressions/DMatDMatMultExpr.h
C
bsd-2-clause
440,644
cask 'thunderbird' do version '68.2.1' language 'cs' do sha256 '42e9d68dbdc55737e94beb2d5ca9feb8b7bdb5595af44f762a7e7374ee1542ac' 'cs' end language 'de' do sha256 '645dd8b8562b71685026a38146177e2b2bf98682d2e8c6cf50e781d272365f28' 'de' end language 'en-GB' do sha256 '078b869716f3ce15ef6859a90963e18eb1e833e4bfb5751e6cd7b14471a14ec0' 'en-GB' end language 'en', default: true do sha256 'ee958d87a62148603dc22f214cc614672790e315c407beab98455097dc783844' 'en-US' end language 'fr' do sha256 '3f478fd52d7d672be7054f077398356769ba2e97a5f8799a18d04ef3a932508a' 'fr' end language 'gl' do sha256 '2334660bc2debdc6e4163e0ab9f63ae96081f59cc1e2f9119cb46d0ff371aa91' 'gl' end language 'it' do sha256 'ae9ce349766ce9201fe30c31a00ac52a6c088c48705478e8d013d81ab6cc8406' 'it' end language 'ja' do sha256 '91d88ec05097e90d37cbd4004aa6aadce1ee7aa9df15c78d16020ef115b9c057' 'ja-JP-mac' end language 'nl' do sha256 '258a560acf60e7e480bd930b811a46a1abca5a9fd26fbc2780d49395a62412d6' 'nl' end language 'pl' do sha256 '8711d6024760a54a6052592d24c42ecf910f920f6fe611157b01b920dbf83116' 'pl' end language 'pt' do sha256 '54206086abcd21971ad75348c9ca638d24759e8b709ed3d421caaddb66c3807e' 'pt-PT' end language 'pt-BR' do sha256 '73225789bfc1089d2011a070022212d1b6046858ef418cf79901493513cb8dba' 'pt-BR' end language 'ru' do sha256 'c13b7a6e562dd7baf03f76933f70f84d526eeaf3bb8b5f78e59ea2c8a8ad7ff6' 'ru' end language 'uk' do sha256 '98ef0f4df2e1d961a1bef87a23a0eb1fbfb181a389932ede25842fb7da788897' 'uk' end language 'zh-TW' do sha256 '35d8b5ee59117af0d59308182a0fdba7baa6c51963b60bb705011400e9147eb5' 'zh-TW' end language 'zh' do sha256 '746a0ee9e8cd2b316b75acb7655bbfcf5a99b7ebe32c26df69783e129c86bfe0' 'zh-CN' end url "https://ftp.mozilla.org/pub/thunderbird/releases/#{version}/mac/#{language}/Thunderbird%20#{version}.dmg" appcast 'https://www.thunderbird.net/en-US/thunderbird/releases/' name 'Mozilla Thunderbird' homepage 'https://www.mozilla.org/thunderbird/' auto_updates true conflicts_with cask: 'thunderbird-beta' app 'Thunderbird.app' zap trash: [ '~/Library/Thunderbird', '~/Library/Caches/Thunderbird', '~/Library/Saved Application State/org.mozilla.thunderbird.savedState', '~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/org.mozilla.thunderbird.sfl*', '~/Library/Preferences/org.mozilla.thunderbird.plist', ] end
jasmas/homebrew-cask
Casks/thunderbird.rb
Ruby
bsd-2-clause
2,682
# CardEngine Card Engine for the swift language Codes written in Xcode 6.3
ckilimci/CardEngine
README.md
Markdown
bsd-2-clause
79
/* * Copyright (c) 2004-2010, Kohsuke Kawaguchi * All rights reserved. * * 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. * * 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 OWNER 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. */ package org.kohsuke.stapler; import org.kohsuke.stapler.Header.HandlerImpl; import javax.servlet.ServletException; import static java.lang.annotation.ElementType.PARAMETER; import java.lang.annotation.Retention; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Target; import java.lang.annotation.Documented; /** * Indicates that this parameter is bound from HTTP header. * * @author Kohsuke Kawaguchi */ @Retention(RUNTIME) @Target(PARAMETER) @Documented @InjectedParameter(HandlerImpl.class) public @interface Header { /** * HTTP header name. */ String value(); /** * If true, request without this header will be rejected. */ boolean required() default false; class HandlerImpl extends AnnotationHandler<Header> { @Override public Object parse(StaplerRequest request, Header a, Class type, String parameterName) throws ServletException { String name = a.value(); if(name.length()==0) name=parameterName; if(name==null) throw new IllegalArgumentException("Parameter name unavailable neither in the code nor in annotation"); String value = request.getHeader(name); if(a.required() && value==null) throw new ServletException("Required HTTP header "+name+" is missing"); return convert(type,value); } } }
stapler/stapler
core/src/main/java/org/kohsuke/stapler/Header.java
Java
bsd-2-clause
2,817
#ifndef __APPENDER_H__ #define __APPENDER_H__ #include "dgrObject.h" DGR2_NP_BEGIN struct DGR2_API Appender : public DGRObject { virtual bool publish(const Log& log) = 0; virtual void setFilter(Filter* filter) = 0; virtual Filter* getFilter() = 0; virtual void setFormatter(Formatter* formatter) = 0; virtual Formatter* getFormatter() = 0; virtual void destroy(); protected: virtual ~Appender() {} }; NP_END #endif
scofieldzhu/blackconfigurator
trunk/3rd/dbgme/include/appender.h
C
bsd-2-clause
456
--- layout: lesson root: ../.. title: Using Databases and SQL level: novice --- Almost everyone has used spreadsheets, and almost everyone has eventually run up against their limitations. The more complicated a data set is, the harder it is to filter data, express relationships between different rows and columns, or handle missing values. Databases pick up where spreadsheets leave off. While they are not as simple to use if all we want is the sum of a dozen numbers, they can do a lot of things that spreadsheets can't, on much larger data sets, faster. And even if we never need to create a database ourselves, knowing how they work will help us understand why so many of the systems we use behave the way we do, and why they insist on structuring data in certain ways. <div class="toc" markdown="1"> 1. [Selecting Data](01-select.html) 2. [Sorting and Removing Duplicates](02-sort-dup.html) 3. [Filtering](03-filter.html) 4. [Calculating New Values](04-calc.html) 5. [Missing Data](05-null.html) 6. [Aggregation](06-agg.html) 7. [Combining Data](07-join.html) 8. [Creating and Modifying Data](08-create.html) 9. [Programming with Databases](09-prog.html) </div>
selimnairb/2014-02-25-swctest
novice/sql/index.md
Markdown
bsd-2-clause
1,181
/* TODO : finish this */ #define NDK_HTTP_MAIN_CONF NGX_HTTP_MAIN_CONF #define NDK_HTTP_SRV_CONF NGX_HTTP_SRV_CONF #define NDK_HTTP_SIF_CONF NGX_HTTP_SIF_CONF #define NDK_HTTP_LOC_CONF NGX_HTTP_LOC_CONF #define NDK_HTTP_LIF_CONF NGX_HTTP_LIF_CONF #define NDK_HTTP_UPS_CONF NGX_HTTP_UPS_CONF #define NDK_MAIN_CONF NGX_MAIN_CONF #define NDK_ANY_CONF NGX_ANY_CONF /* compound locations */ #define NDK_HTTP_MAIN_SRV_CONF NDK_HTTP_MAIN_CONF|NDK_HTTP_SRV_CONF #define NDK_HTTP_MAIN_SIF_CONF NDK_HTTP_MAIN_CONF|NDK_HTTP_SRV_SIF_CONF #define NDK_HTTP_MAIN_LOC_CONF NDK_HTTP_MAIN_CONF|NDK_HTTP_LOC_CONF #define NDK_HTTP_MAIN_LIF_CONF NDK_HTTP_MAIN_CONF|NDK_HTTP_LOC_LIF_CONF #define NDK_HTTP_SRV_SIF_CONF NDK_HTTP_SRV_CONF|NDK_HTTP_SIF_CONF #define NDK_HTTP_SRV_LOC_CONF NDK_HTTP_SRV_CONF|NDK_HTTP_LOC_CONF #define NDK_HTTP_SRV_LOC_LIF_CONF NDK_HTTP_SRV_CONF|NDK_HTTP_LOC_LIF_CONF #define NDK_HTTP_SRV_SIF_LOC_CONF NDK_HTTP_SRV_SIF_CONF|NDK_HTTP_LOC_CONF #define NDK_HTTP_SRV_SIF_LOC_LIF_CONF NDK_HTTP_SRV_SIF_CONF|NDK_HTTP_LOC_LIF_CONF #define NDK_HTTP_LOC_LIF_CONF NDK_HTTP_LOC_CONF|NDK_HTTP_LIF_CONF #define NDK_HTTP_MAIN_SRV_LOC_CONF NDK_HTTP_MAIN_CONF|NDK_HTTP_SRV_LOC_CONF #define NDK_HTTP_MAIN_SRV_LIF_CONF NDK_HTTP_MAIN_CONF|NDK_HTTP_SRV_LIF_CONF #define NDK_HTTP_MAIN_SIF_LOC_CONF NDK_HTTP_MAIN_CONF|NDK_HTTP_SIF_LOC_CONF #define NDK_HTTP_MAIN_SRV_SIF_LOC_LIF_CONF NDK_HTTP_SRV_SIF_LOC_LIF_CONF|NDK_MAIN_CONF #define NDK_HTTP_CONF NDK_HTTP_MAIN_SRV_SIF_LOC_LIF_CONF #define NDK_HTTP_ANY_CONF NDK_HTTP_CONF|NDK_HTTP_UPS_CONF /* property offsets NOTE : ngx_module_main_conf_t etc should be defined in the module's .c file before the commands */ #define NDK_HTTP_MAIN_CONF_PROP(p) NGX_HTTP_MAIN_CONF_OFFSET, offsetof (ndk_module_main_conf_t, p) #define NDK_HTTP_SRV_CONF_PROP(p) NGX_HTTP_SRV_CONF_OFFSET, offsetof (ndk_module_srv_conf_t, p) #define NDK_HTTP_LOC_CONF_PROP(p) NGX_HTTP_LOC_CONF_OFFSET, offsetof (ndk_module_loc_conf_t, p)
caidongyun/nginx-openresty-windows
ngx_devel_kit-0.2.19/auto/src/conf_cmd_basic.h
C
bsd-2-clause
2,491
/** * @module ol/control/ZoomSlider */ // FIXME should possibly show tooltip when dragging? import {inherits} from '../index.js'; import ViewHint from '../ViewHint.js'; import Control from '../control/Control.js'; import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js'; import {easeOut} from '../easing.js'; import {listen} from '../events.js'; import Event from '../events/Event.js'; import EventType from '../events/EventType.js'; import {clamp} from '../math.js'; import PointerEventType from '../pointer/EventType.js'; import PointerEventHandler from '../pointer/PointerEventHandler.js'; /** * @classdesc * A slider type of control for zooming. * * Example: * * map.addControl(new ol.control.ZoomSlider()); * * @constructor * @extends {ol.control.Control} * @param {olx.control.ZoomSliderOptions=} opt_options Zoom slider options. * @api */ const ZoomSlider = function(opt_options) { const options = opt_options ? opt_options : {}; /** * Will hold the current resolution of the view. * * @type {number|undefined} * @private */ this.currentResolution_ = undefined; /** * The direction of the slider. Will be determined from actual display of the * container and defaults to ol.control.ZoomSlider.Direction_.VERTICAL. * * @type {ol.control.ZoomSlider.Direction_} * @private */ this.direction_ = ZoomSlider.Direction_.VERTICAL; /** * @type {boolean} * @private */ this.dragging_; /** * @type {number} * @private */ this.heightLimit_ = 0; /** * @type {number} * @private */ this.widthLimit_ = 0; /** * @type {number|undefined} * @private */ this.previousX_; /** * @type {number|undefined} * @private */ this.previousY_; /** * The calculated thumb size (border box plus margins). Set when initSlider_ * is called. * @type {ol.Size} * @private */ this.thumbSize_ = null; /** * Whether the slider is initialized. * @type {boolean} * @private */ this.sliderInitialized_ = false; /** * @type {number} * @private */ this.duration_ = options.duration !== undefined ? options.duration : 200; const className = options.className !== undefined ? options.className : 'ol-zoomslider'; const thumbElement = document.createElement('button'); thumbElement.setAttribute('type', 'button'); thumbElement.className = className + '-thumb ' + CLASS_UNSELECTABLE; const containerElement = document.createElement('div'); containerElement.className = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL; containerElement.appendChild(thumbElement); /** * @type {ol.pointer.PointerEventHandler} * @private */ this.dragger_ = new PointerEventHandler(containerElement); listen(this.dragger_, PointerEventType.POINTERDOWN, this.handleDraggerStart_, this); listen(this.dragger_, PointerEventType.POINTERMOVE, this.handleDraggerDrag_, this); listen(this.dragger_, PointerEventType.POINTERUP, this.handleDraggerEnd_, this); listen(containerElement, EventType.CLICK, this.handleContainerClick_, this); listen(thumbElement, EventType.CLICK, Event.stopPropagation); const render = options.render ? options.render : ZoomSlider.render; Control.call(this, { element: containerElement, render: render }); }; inherits(ZoomSlider, Control); /** * @inheritDoc */ ZoomSlider.prototype.disposeInternal = function() { this.dragger_.dispose(); Control.prototype.disposeInternal.call(this); }; /** * The enum for available directions. * * @enum {number} * @private */ ZoomSlider.Direction_ = { VERTICAL: 0, HORIZONTAL: 1 }; /** * @inheritDoc */ ZoomSlider.prototype.setMap = function(map) { Control.prototype.setMap.call(this, map); if (map) { map.render(); } }; /** * Initializes the slider element. This will determine and set this controls * direction_ and also constrain the dragging of the thumb to always be within * the bounds of the container. * * @private */ ZoomSlider.prototype.initSlider_ = function() { const container = this.element; const containerSize = { width: container.offsetWidth, height: container.offsetHeight }; const thumb = container.firstElementChild; const computedStyle = getComputedStyle(thumb); const thumbWidth = thumb.offsetWidth + parseFloat(computedStyle['marginRight']) + parseFloat(computedStyle['marginLeft']); const thumbHeight = thumb.offsetHeight + parseFloat(computedStyle['marginTop']) + parseFloat(computedStyle['marginBottom']); this.thumbSize_ = [thumbWidth, thumbHeight]; if (containerSize.width > containerSize.height) { this.direction_ = ZoomSlider.Direction_.HORIZONTAL; this.widthLimit_ = containerSize.width - thumbWidth; } else { this.direction_ = ZoomSlider.Direction_.VERTICAL; this.heightLimit_ = containerSize.height - thumbHeight; } this.sliderInitialized_ = true; }; /** * Update the zoomslider element. * @param {ol.MapEvent} mapEvent Map event. * @this {ol.control.ZoomSlider} * @api */ ZoomSlider.render = function(mapEvent) { if (!mapEvent.frameState) { return; } if (!this.sliderInitialized_) { this.initSlider_(); } const res = mapEvent.frameState.viewState.resolution; if (res !== this.currentResolution_) { this.currentResolution_ = res; this.setThumbPosition_(res); } }; /** * @param {Event} event The browser event to handle. * @private */ ZoomSlider.prototype.handleContainerClick_ = function(event) { const view = this.getMap().getView(); const relativePosition = this.getRelativePosition_( event.offsetX - this.thumbSize_[0] / 2, event.offsetY - this.thumbSize_[1] / 2); const resolution = this.getResolutionForPosition_(relativePosition); view.animate({ resolution: view.constrainResolution(resolution), duration: this.duration_, easing: easeOut }); }; /** * Handle dragger start events. * @param {ol.pointer.PointerEvent} event The drag event. * @private */ ZoomSlider.prototype.handleDraggerStart_ = function(event) { if (!this.dragging_ && event.originalEvent.target === this.element.firstElementChild) { this.getMap().getView().setHint(ViewHint.INTERACTING, 1); this.previousX_ = event.clientX; this.previousY_ = event.clientY; this.dragging_ = true; } }; /** * Handle dragger drag events. * * @param {ol.pointer.PointerEvent|Event} event The drag event. * @private */ ZoomSlider.prototype.handleDraggerDrag_ = function(event) { if (this.dragging_) { const element = this.element.firstElementChild; const deltaX = event.clientX - this.previousX_ + parseInt(element.style.left, 10); const deltaY = event.clientY - this.previousY_ + parseInt(element.style.top, 10); const relativePosition = this.getRelativePosition_(deltaX, deltaY); this.currentResolution_ = this.getResolutionForPosition_(relativePosition); this.getMap().getView().setResolution(this.currentResolution_); this.setThumbPosition_(this.currentResolution_); this.previousX_ = event.clientX; this.previousY_ = event.clientY; } }; /** * Handle dragger end events. * @param {ol.pointer.PointerEvent|Event} event The drag event. * @private */ ZoomSlider.prototype.handleDraggerEnd_ = function(event) { if (this.dragging_) { const view = this.getMap().getView(); view.setHint(ViewHint.INTERACTING, -1); view.animate({ resolution: view.constrainResolution(this.currentResolution_), duration: this.duration_, easing: easeOut }); this.dragging_ = false; this.previousX_ = undefined; this.previousY_ = undefined; } }; /** * Positions the thumb inside its container according to the given resolution. * * @param {number} res The res. * @private */ ZoomSlider.prototype.setThumbPosition_ = function(res) { const position = this.getPositionForResolution_(res); const thumb = this.element.firstElementChild; if (this.direction_ == ZoomSlider.Direction_.HORIZONTAL) { thumb.style.left = this.widthLimit_ * position + 'px'; } else { thumb.style.top = this.heightLimit_ * position + 'px'; } }; /** * Calculates the relative position of the thumb given x and y offsets. The * relative position scales from 0 to 1. The x and y offsets are assumed to be * in pixel units within the dragger limits. * * @param {number} x Pixel position relative to the left of the slider. * @param {number} y Pixel position relative to the top of the slider. * @return {number} The relative position of the thumb. * @private */ ZoomSlider.prototype.getRelativePosition_ = function(x, y) { let amount; if (this.direction_ === ZoomSlider.Direction_.HORIZONTAL) { amount = x / this.widthLimit_; } else { amount = y / this.heightLimit_; } return clamp(amount, 0, 1); }; /** * Calculates the corresponding resolution of the thumb given its relative * position (where 0 is the minimum and 1 is the maximum). * * @param {number} position The relative position of the thumb. * @return {number} The corresponding resolution. * @private */ ZoomSlider.prototype.getResolutionForPosition_ = function(position) { const fn = this.getMap().getView().getResolutionForValueFunction(); return fn(1 - position); }; /** * Determines the relative position of the slider for the given resolution. A * relative position of 0 corresponds to the minimum view resolution. A * relative position of 1 corresponds to the maximum view resolution. * * @param {number} res The resolution. * @return {number} The relative position value (between 0 and 1). * @private */ ZoomSlider.prototype.getPositionForResolution_ = function(res) { const fn = this.getMap().getView().getValueForResolutionFunction(); return 1 - fn(res); }; export default ZoomSlider;
planetlabs/ol3
src/ol/control/ZoomSlider.js
JavaScript
bsd-2-clause
9,856
#!/usr/bin/env python3 # Copyright (C) 2016 Job Snijders <job@instituut.net> # # This file is part of rtrsub # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. 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. # # 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. import rtrsub version = rtrsub.__version__ import codecs import os import sys from os.path import abspath, dirname, join from setuptools import setup, find_packages here = abspath(dirname(__file__)) def parse_requirements(filename): """ load requirements from a pip requirements file """ lineiter = (line.strip() for line in open(filename)) return [line for line in lineiter if line and not line.startswith("#")] with codecs.open(join(here, 'README.md'), encoding='utf-8') as f: README = f.read() if sys.argv[-1] == 'publish': os.system('python3 setup.py sdist upload') print("You probably want to also tag the version now:") print((" git tag -a %s -m 'version %s'" % (version, version))) print(" git push --tags") sys.exit() install_reqs = parse_requirements('requirements.txt') reqs = install_reqs setup( name='rtrsub', version=version, maintainer="Job Snijders", maintainer_email='job@instituut.net', url='https://github.com/job/rtrsub', description='RTR Substitution', long_description=README, long_description_content_type="text/markdown", license='BSD 2-Clause', keywords='rpki prefix routing networking', setup_requires=reqs, install_requires=reqs, classifiers=[ 'Intended Audience :: Developers', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: System :: Networking', 'License :: OSI Approved :: BSD License', 'Programming Language :: Python :: 3 :: Only' ], packages=find_packages(exclude=['tests', 'tests.*']), entry_points={'console_scripts': ['rtrsub = rtrsub.rtrsub:main']}, )
job/rtrsub
setup.py
Python
bsd-2-clause
3,054
package sim.net; public class BrokenLinkException extends RoutingException { /** * @param string */ public BrokenLinkException(String string) { super(string); } }
bramp/p2psim
src/sim/net/BrokenLinkException.java
Java
bsd-2-clause
185
<?php # Copyright (c) 2009-2015 Yubico AB # All rights reserved. # # 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. # # 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 # OWNER 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. require_once 'ykval-common.php'; require_once 'ykval-config.php'; require_once 'ykval-synclib.php'; header('content-type: text/plain'); if (empty($_SERVER['QUERY_STRING'])) { sendResp(S_MISSING_PARAMETER, $myLog); } $ipaddr = $_SERVER['REMOTE_ADDR']; $allowed = $baseParams['__YKVAL_ALLOWED_SYNC_POOL__']; $myLog = new Log('ykval-sync'); $myLog->addField('ip', $ipaddr); $myLog->log(LOG_INFO, 'Request: ' . $_SERVER['QUERY_STRING']); $myLog->log(LOG_DEBUG, "Received request from $ipaddr"); // verify request sent by whitelisted address if (in_array($ipaddr, $allowed, TRUE) === FALSE) { $myLog->log(LOG_NOTICE, "Operation not allowed from IP $ipaddr"); $myLog->log(LOG_DEBUG, "Remote IP $ipaddr not listed in allowed sync pool : " . implode(', ', $allowed)); sendResp(S_OPERATION_NOT_ALLOWED, $myLog); } // define requirements on protocol $syncParams = array( 'modified' => NULL, 'otp' => NULL, 'nonce' => NULL, 'yk_publicname' => NULL, 'yk_counter' => NULL, 'yk_use' => NULL, 'yk_high' => NULL, 'yk_low' => NULL ); // extract values from HTTP request $tmp_log = 'Received '; foreach ($syncParams as $param => $value) { $value = getHttpVal($param, NULL); if ($value == NULL) { $myLog->log(LOG_NOTICE, "Received request with parameter[s] ($param) missing value"); sendResp(S_MISSING_PARAMETER, $myLog); } $syncParams[$param] = $value; $tmp_log .= "$param=$value "; } $myLog->log(LOG_INFO, $tmp_log); $sync = new SyncLib('ykval-sync:synclib'); $sync->addField('ip', $ipaddr); if (! $sync->isConnected()) { sendResp(S_BACKEND_ERROR, $myLog); } // at this point we should have the otp so let's add it to the logging module $myLog->addField('otp', $syncParams['otp']); $sync->addField('otp', $syncParams['otp']); // verify correctness of input parameters foreach (array('modified','yk_counter', 'yk_use', 'yk_high', 'yk_low') as $param) { // -1 is valid except for modified if ($param !== 'modified' && $syncParams[$param] === '-1') continue; // [0-9]+ if ($syncParams[$param] !== '' && ctype_digit($syncParams[$param])) continue; $myLog->log(LOG_NOTICE, "Input parameters $param not correct"); sendResp(S_MISSING_PARAMETER, $myLog); } // get local counter data $yk_publicname = $syncParams['yk_publicname']; if (($localParams = $sync->getLocalParams($yk_publicname)) === FALSE) { $myLog->log(LOG_NOTICE, 'Invalid Yubikey ' . $yk_publicname); sendResp(S_BACKEND_ERROR, $myLog); } // conditional update local database $sync->updateDbCounters($syncParams); $myLog->log(LOG_DEBUG, 'Local params ', $localParams); $myLog->log(LOG_DEBUG, 'Sync request params ', $syncParams); if ($sync->countersHigherThan($localParams, $syncParams)) { $myLog->log(LOG_WARNING, 'Remote server out of sync.'); } if ($sync->countersEqual($localParams, $syncParams)) { if ($syncParams['modified'] == $localParams['modified'] && $syncParams['nonce'] == $localParams['nonce']) { /** * This is not an error. When the remote server received an OTP to verify, it would * have sent out sync requests immediately. When the required number of responses had * been received, the current implementation discards all additional responses (to * return the result to the client as soon as possible). If our response sent last * time was discarded, we will end up here when the background ykval-queue processes * the sync request again. */ $myLog->log(LOG_INFO, 'Sync request unnecessarily sent'); } if ($syncParams['modified'] != $localParams['modified'] && $syncParams['nonce'] == $localParams['nonce']) { $deltaModified = $syncParams['modified'] - $localParams['modified']; if ($deltaModified < -1 || $deltaModified > 1) { $myLog->log(LOG_WARNING, "We might have a replay. 2 events at different times have generated the same counters. The time difference is $deltaModified seconds"); } } if ($syncParams['nonce'] != $localParams['nonce']) { $myLog->log(LOG_WARNING, 'Remote server has received a request to validate an already validated OTP '); } } if ($localParams['active'] != 1) { /** * The remote server has accepted an OTP from a YubiKey which we would not. * We still needed to update our counters with the counters from the OTP though. */ $myLog->log(LOG_WARNING, "Received sync-request for de-activated Yubikey $yk_publicname - check database synchronization!!!"); sendResp(S_BAD_OTP, $myLog); } $extra = array( 'modified' => $localParams['modified'], 'nonce' => $localParams['nonce'], 'yk_publicname' => $yk_publicname, 'yk_counter' => $localParams['yk_counter'], 'yk_use' => $localParams['yk_use'], 'yk_high' => $localParams['yk_high'], 'yk_low' => $localParams['yk_low'] ); sendResp(S_OK, $myLog, '', $extra);
ahojjati/yubikey-val
ykval-sync.php
PHP
bsd-2-clause
6,080
<?php /* Template Name: Archive */ ?> <?php get_header(); ?> <div id="main"> <div id="archive-wrapper"> <?php query_posts('cat=&showposts=-1'); ?> <?php while (have_posts()) : the_post(); ?> <div class="post-archive-entry"> <div class="post-title"><h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1></div> <div class="post-date"><?php the_time('Y-m-d') ?></div> <div class="post-categories"><?php the_category(', '); ?></div> </div> <?php endwhile; ?> </div> </div> <?php get_footer(); ?>
syouts/wordpress-theme-ivory
archives.php
PHP
bsd-2-clause
565
package net.virtualvoid.bytecode package snippets.hosc import org.specs.Specification import Methods._ import Bytecode.Instructions._ import backend.ASM object Snippets extends Specification { "Examples from the article" should { "compile and execute correctly" in { "figure4" in { val f = ASM.compile( classOf[Integer], classOf[Integer])( param => ret => frame => frame ~ param.load ~ method((x: Integer) => x.intValue) ~ bipush(1) ~ iadd ~ method((x: Int) => Integer.valueOf(x)) ~ ret.jmp) f(0) must be_==(1) f(12) must be_==(13) } "figure6" in { def fCountdown[ST <: Stack] = ((f: F[ST]) => f ~ bipush(5) ~ withTargetHere((target: Target[ST**Int]) => (_: F[ST**Int]) ~ dup ~ ifne(_ ~ dup ~ method(printme(_: Int)) ~ bipush(1) ~ isub ~ target.jmp)) ~ method(Integer.valueOf(_: Int))) val code = ASM.compile(classOf[Integer], classOf[Integer])( param => ret => _ ~ fCountdown ~ ret.jmp ) resetPrintBuffer code(28) must be_==(0) printBuffer must be_==(Seq(5, 4, 3, 2, 1)) } "chapter41Example" in { val code = ASM.compile(classOf[Integer], classOf[Integer])(param => ret => _ ~ param.load ~ method((_: Integer).intValue) ~ iterate[Nil ** Int, Nil ** Int](self => _ ~ dup ~ method(printme(_: Int)) ~ bipush(1) ~ isub ~ dup ~ ifne2(self, nop) ) ~ method(Integer.valueOf(_: Int)) ~ ret.jmp) resetPrintBuffer code(13) must be_==(0) printBuffer must be_==(Seq(13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)) } "chapter66Example" in { val code = ASM.compile(classOf[Integer], classOf[String])(param => ret => _ ~ param.load ~ method((_: Integer).intValue) ~ bipush(5) ~ isub ~ ifne(_ ~ ldc(" does not equal 5") ~ ret.jmp) ~ ldc(" equals 5") ~ ret.jmp) code(5) must be_==(" equals 5") code(12) must be_==(" does not equal 5") } } } val printBuffer = collection.mutable.Buffer.empty[Int] def resetPrintBuffer { printBuffer.clear } def printme (i: Int ){ //System.out.println (i) printBuffer += i } }
jrudolph/bytecode
src/test/scala/net/virtualvoid/bytecode/snippets/hosc/Snippets.scala
Scala
bsd-2-clause
2,550
local awful = require("awful") awful.rules = require("awful.rules") require("awful.autofocus") modkey = "Mod4" config_path = awful.util.getdir("config") globalkeys = awful.util.table.join( -- command keys awful.key({modkey}, "Return", function() awful.spawn(terminal) end), awful.key({modkey}, "v", function() awful.spawn("firefox") end), awful.key({modkey}, "r", function() awful.spawn("rofi -show combi") end), awful.key({modkey, "Control"}, "r", awesome.restart), awful.key({modkey, "Control"}, "q", awesome.quit), awful.key({modkey,}, "Escape", awful.tag.history.restore), -- the 'j' key awful.key({modkey}, "j", function() awful.client.focus.byidx(1) if client.focus then client.focus:raise() end end), awful.key({modkey, "Shift"}, "j", function() awful.client.swap.byidx(1) end), awful.key({modkey, "Control"}, "j", function() awful.screen.focus_relative( 1) end), awful.key({modkey, "Control", "Shift"}, "j", function() awful.tag.incncol(1) end), -- the 'k' key awful.key({modkey}, "k", function() awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end end), awful.key({modkey, "Shift"}, "k", function() awful.client.swap.byidx(-1) end), awful.key({modkey, "Control"}, "k", function() awful.screen.focus_relative(-1) end), awful.key({modkey, "Control", "Shift"}, "k", function() awful.tag.incncol(-1) end), -- the 'h' key awful.key({modkey,}, "h", awful.tag.viewprev), awful.key({modkey, "Control"}, "h", function() awful.tag.incmwfact(-0.05) end), awful.key({modkey, "Control", "Shift"}, "h", function() awful.tag.incnmaster(1) end), awful.key({modkey, "Shift"}, "h", function() if client.focus then local idx = awful.tag.getidx()-1 if idx == 0 then idx = 9 end client.focus:move_to_tag(awful.screen.focused().tags[idx]) end awful.tag.viewprev() end), -- the 'l' key awful.key({modkey}, "l", awful.tag.viewnext), awful.key({modkey, "Control"}, "l", function() awful.tag.incmwfact( 0.05) end), awful.key({modkey, "Control", "Shift"}, "l", function() awful.tag.incnmaster(-1) end), awful.key({modkey, "Shift"}, "l", function() if client.focus then local idx = awful.tag.getidx()+1 if idx == 10 then idx = 1 end client.focus:move_to_tag(awful.screen.focused().tags[idx]) end awful.tag.viewnext() end), -- the 'o' key awful.key({modkey,}, "o", function() awful.screen.focus_relative(1) end), awful.key({modkey, "Shift"}, "o", awful.client.movetoscreen), -- volume, brightness and print awful.key({}, "XF86AudioRaiseVolume", function() awful.util.spawn("amixer -D pulse sset Master 10%+ unmute") end), awful.key({}, "XF86AudioLowerVolume", function() awful.util.spawn("amixer -D pulse sset Master 10%- unmute") end), awful.key({}, "XF86AudioMute", function() awful.util.spawn("amixer -D pulse sset Master toggle") end), awful.key({}, "XF86MonBrightnessDown", function() awful.spawn.with_shell(config_path .. 'xbacklight_sqrt -dec 2') end), awful.key({}, "XF86MonBrightnessUp", function() awful.spawn.with_shell(config_path .. 'xbacklight_sqrt -inc 3') end), awful.key({}, "Print", function() awful.util.spawn("scrot -e 'mv $f ~/tmp/screenshots/ 2>/dev/null'") end), -- the 'space' key awful.key({modkey}, "space", function() awful.layout.inc(1, awful.screen.focused(), awful.layout.layouts) end) ) -- number keys: for i = 1, 9 do globalkeys = awful.util.table.join(globalkeys, awful.key({modkey}, "#" .. i + 9, function() local screen = awful.screen.focused() local tag = screen.tags[i] if tag then tag:view_only() end end), awful.key({ modkey, "Control" }, "#" .. i + 9, function() local screen = awful.screen.focused() local tag = screen.tags[i] if tag then awful.tag.viewtoggle(tag) end end), awful.key({ modkey, "Shift" }, "#" .. i + 9, function() if client.focus then local tag = client.focus.screen.tags[i] if tag then client.focus:move_to_tag(tag) end end local screen = awful.screen.focused() local tag = screen.tags[i] if tag then tag:view_only() end end), awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function () if client.focus then local tag = client.focus.screen.tags[i] if tag then client.focus:toggle_tag(tag) end end end) ) end root.keys(globalkeys) root.buttons( awful.util.table.join( awful.button({}, 1, function(c) client.focus = c end) ) ) clientkeys = awful.util.table.join( awful.key({modkey}, "m", function(c) c.maximized = not c.maximized c:raise() end, {description = "maximize", group = "client"}), awful.key({modkey,}, "f", function(c) c.fullscreen = not c.fullscreen end), awful.key({modkey, "Control"}, "c", function(c) c:kill() end), awful.key({modkey, "Shift"}, "o", function(c) c.move_to_screen() end) ) clientbuttons = awful.util.table.join( awful.button({}, 1, function(c) client.focus = c end) )
jonathf/awesome
keybinds.lua
Lua
bsd-2-clause
5,662
/** * @file MazeField.h * @author Albert Uchytil (xuchyt03), Tomas Coufal (xcoufa09) * @brief Class defining the the field on the board */ #ifndef MAZEFIELD_H #define MAZEFIELD_H #include "MazeCard.h" /// @brief Class containig the field data like card, and handles the neighborhood class MazeField { public: MazeField(int r, int c); virtual ~MazeField(); int row(); int col(); MazeCard getCard(); MazeCard *getCardP(); void putCard(MazeCard c); protected: private: int _row; int _col; MazeCard _cardL; }; #endif // MAZEFIELD_H
tumido/ICP-Project
src/include/MazeField.h
C
bsd-2-clause
627
#ifndef CAMERA_H #define CAMERA_H #include "GameObjects/GameObject.h" #include "GameObjects/Billboard.h" #include "GameObjects/Weapon.h" #include "Models/Armature.hpp" #include <iostream> #include <cmath> #include <glm/glm.hpp> #include <glm/gtx/transform.hpp> #include <glm/gtx/rotate_vector.hpp> #include <SDL/SDL.h> class Weapon; class Camera : public GameObject{ public: Camera(ObjectData* objectData, float windowSize[2], DataBlock& def, GameState* state); ~Camera(); bool holdingForward; bool holdingBackward; bool holdingLeftStrafe; bool holdingRightStrafe; bool playerIsFiring; void fire(); void handleMouseMove(int mouseX, int mouseY); void move(double deltaTime, Camera* player, std::list<GameObject*>* levelObjects); void render(GameState* state); void commitMovement(GameState* state){ position += movement; head += movement; origin += movement; if(movement.y == 0.0f) ground = true; } float getPitchSensitivity() { return pitchSensitivity; } void setPitchSensitivity(float value) { pitchSensitivity = value; } float getYawSensitivity() { return yawSensitivity; } void setYawSensitivity(float value) { yawSensitivity = value; } glm::vec3 getPosition() const {return position;} void setXPos(double x) {position.x = x;} void setYPos(double y) {position.y = y;} void setZPos(double z) {position.z = z;} glm::vec3 getHead() const { return head;} void setXHead(double x) {head.x = x;} void setYHead(double y) {head.y = y;} void setZHead(double z) {head.z = z;} glm::vec3 getOrigin() const { return origin;} void setXOrigin(double x) {origin.x = x;} void setYOrigin(double y) {origin.y = y;} void setZOrigin(double z) {origin.z = z;} glm::vec3 getFront() const { return front;} void setXFront(double x) {front.x = x;} void setYFront(double y) {front.y = y;} void setZFront(double z) {front.z = z;} glm::vec3 getRight() const { return right;} void setXRight(double x) {right.x = x;} void setYRight(double y) {right.y = y;} void setZRight(double z) {right.z = z;} glm::vec3 getUp() const { return up;} void setXUp(double x) {up.x = x;} void setYUp(double y) {up.y = y;} void setZUp(double z) {up.z = z;} private: glm::vec3 head; glm::vec3 origin; //for glmLootAt glm::vec3 front; glm::vec3 up; glm::vec3 right; float rotHorizontal, rotVertical; Billboard* crosshairs; Billboard* healthMeter; TTF_Font* healthMeterFont; std::string nameCurrentWeapon; Weapon* currentWeapon; double movementSpeedFactor; double pitchSensitivity; double yawSensitivity; int windowWidth; int windowHeight; int windowMidX; int windowMidY; void initCamera(); }; #endif
kSkip/MereEngine
include/GameObjects/Camera.h
C
bsd-2-clause
3,166
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_02) on Mon Sep 08 12:46:29 CEST 2014 --> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"> <title>ContentFilterable (Gradle API 2.1)</title> <meta name="date" content="2014-09-08"> <link rel="stylesheet" type="text/css" href="../../../../javadoc.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="ContentFilterable (Gradle API 2.1)"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../index-all.html">Index</a></li> <li><a href="../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../org/gradle/api/file/ConfigurableFileTree.html" title="interface in org.gradle.api.file"><span class="strong">Prev Class</span></a></li> <li><a href="../../../../org/gradle/api/file/CopyProcessingSpec.html" title="interface in org.gradle.api.file"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../../index.html?org/gradle/api/file/ContentFilterable.html" target="_top">Frames</a></li> <li><a href="ContentFilterable.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Constr&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Constr&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <!-- ======== START OF CLASS DATA ======== --> <div class="header"> <div class="subTitle">org.gradle.api.file</div> <h2 title="Interface ContentFilterable" class="title">Interface ContentFilterable</h2> </div> <div class="contentContainer"> <div class="description"> <ul class="blockList"> <li class="blockList"> <dl> <dt>All Known Subinterfaces:</dt> <dd><a href="../../../../org/gradle/api/file/CopyProcessingSpec.html" title="interface in org.gradle.api.file">CopyProcessingSpec</a>, <a href="../../../../org/gradle/api/file/CopySpec.html" title="interface in org.gradle.api.file">CopySpec</a>, <a href="../../../../org/gradle/api/file/FileCopyDetails.html" title="interface in org.gradle.api.file">FileCopyDetails</a></dd> </dl> <dl> <dt>All Known Implementing Classes:</dt> <dd><a href="../../../../org/gradle/api/tasks/bundling/AbstractArchiveTask.html" title="class in org.gradle.api.tasks.bundling">AbstractArchiveTask</a>, <a href="../../../../org/gradle/api/tasks/AbstractCopyTask.html" title="class in org.gradle.api.tasks">AbstractCopyTask</a>, <a href="../../../../org/gradle/api/tasks/Copy.html" title="class in org.gradle.api.tasks">Copy</a>, <a href="../../../../org/gradle/language/jvm/tasks/ProcessResources.html" title="class in org.gradle.language.jvm.tasks">ProcessResources</a>, <a href="../../../../org/gradle/api/tasks/Sync.html" title="class in org.gradle.api.tasks">Sync</a>, <a href="../../../../org/gradle/api/tasks/bundling/Tar.html" title="class in org.gradle.api.tasks.bundling">Tar</a>, <a href="../../../../org/gradle/api/tasks/bundling/Zip.html" title="class in org.gradle.api.tasks.bundling">Zip</a></dd> </dl> <hr> <br> <pre>public interface <span class="strong">ContentFilterable</span></pre> <div class="block">Represents some binary resource whose content can be filtered.</div> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <!-- ========== METHOD SUMMARY =========== --> <ul class="blockList"> <li class="blockList"><a name="method_summary"> <!-- --> </a> <h3>Method Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr class="altColor"> <td class="colFirst"><code><a href="../../../../org/gradle/api/file/ContentFilterable.html" title="interface in org.gradle.api.file">ContentFilterable</a></code></td> <td class="colLast"><code><strong><a href="../../../../org/gradle/api/file/ContentFilterable.html#expand(java.util.Map)">expand</a></strong>(<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,?&gt;&nbsp;properties)</code> <div class="block">Expands property references in each file as it is copied.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../../org/gradle/api/file/ContentFilterable.html" title="interface in org.gradle.api.file">ContentFilterable</a></code></td> <td class="colLast"><code><strong><a href="../../../../org/gradle/api/file/ContentFilterable.html#filter(java.lang.Class)">filter</a></strong>(<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;? extends <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/FilterReader.html?is-external=true" title="class or interface in java.io">FilterReader</a>&gt;&nbsp;filterType)</code> <div class="block">Adds a content filter to be used during the copy.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><code><a href="../../../../org/gradle/api/file/ContentFilterable.html" title="interface in org.gradle.api.file">ContentFilterable</a></code></td> <td class="colLast"><code><strong><a href="../../../../org/gradle/api/file/ContentFilterable.html#filter(groovy.lang.Closure)">filter</a></strong>(<a href="http://groovy.codehaus.org/gapi/groovy/lang/Closure.html?is-external=true" title="class or interface in groovy.lang">Closure</a>&nbsp;closure)</code> <div class="block">Adds a content filter based on the provided closure.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../../org/gradle/api/file/ContentFilterable.html" title="interface in org.gradle.api.file">ContentFilterable</a></code></td> <td class="colLast"><code><strong><a href="../../../../org/gradle/api/file/ContentFilterable.html#filter(java.util.Map, java.lang.Class)">filter</a></strong>(<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,?&gt;&nbsp;properties, <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;? extends <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/FilterReader.html?is-external=true" title="class or interface in java.io">FilterReader</a>&gt;&nbsp;filterType)</code> <div class="block">Adds a content filter to be used during the copy.</div> </td> </tr> </table> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <!-- ============ METHOD DETAIL ========== --> <ul class="blockList"> <li class="blockList"><a name="method_detail"> <!-- --> </a> <h3>Method Detail</h3> <a name="filter(java.util.Map, java.lang.Class)"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>filter</h4> <pre><a href="../../../../org/gradle/api/file/ContentFilterable.html" title="interface in org.gradle.api.file">ContentFilterable</a>&nbsp;filter(<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,?&gt;&nbsp;properties, <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;? extends <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/FilterReader.html?is-external=true" title="class or interface in java.io">FilterReader</a>&gt;&nbsp;filterType)</pre> <div class="block"><p>Adds a content filter to be used during the copy. Multiple calls to filter, add additional filters to the filter chain. Each filter should implement <code>java.io.FilterReader</code>. Include <code>org.apache.tools.ant.filters.*</code> for access to all the standard Ant filters.</p> <p>Filter properties may be specified using groovy map syntax.</p> <p> Examples: <pre> filter(HeadFilter, lines:25, skip:2) filter(ReplaceTokens, tokens:[copyright:'2009', version:'2.3.1']) </pre></div> <dl><dt><span class="strong">Parameters:</span></dt><dd><code>properties</code> - map of filter properties</dd><dd><code>filterType</code> - Class of filter to add</dd> <dt><span class="strong">Returns:</span></dt><dd>this</dd></dl> </li> </ul> <a name="filter(java.lang.Class)"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>filter</h4> <pre><a href="../../../../org/gradle/api/file/ContentFilterable.html" title="interface in org.gradle.api.file">ContentFilterable</a>&nbsp;filter(<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;? extends <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/FilterReader.html?is-external=true" title="class or interface in java.io">FilterReader</a>&gt;&nbsp;filterType)</pre> <div class="block"><p>Adds a content filter to be used during the copy. Multiple calls to filter, add additional filters to the filter chain. Each filter should implement <code>java.io.FilterReader</code>. Include <code>org.apache.tools.ant.filters.*</code> for access to all the standard Ant filters.</p> <p> Examples: <pre> filter(StripJavaComments) filter(com.mycompany.project.CustomFilter) </pre></div> <dl><dt><span class="strong">Parameters:</span></dt><dd><code>filterType</code> - Class of filter to add</dd> <dt><span class="strong">Returns:</span></dt><dd>this</dd></dl> </li> </ul> <a name="filter(groovy.lang.Closure)"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>filter</h4> <pre><a href="../../../../org/gradle/api/file/ContentFilterable.html" title="interface in org.gradle.api.file">ContentFilterable</a>&nbsp;filter(<a href="http://groovy.codehaus.org/gapi/groovy/lang/Closure.html?is-external=true" title="class or interface in groovy.lang">Closure</a>&nbsp;closure)</pre> <div class="block">Adds a content filter based on the provided closure. The Closure will be called with each line (stripped of line endings) and should return a String to replace the line.</div> <dl><dt><span class="strong">Parameters:</span></dt><dd><code>closure</code> - to implement line based filtering</dd> <dt><span class="strong">Returns:</span></dt><dd>this</dd></dl> </li> </ul> <a name="expand(java.util.Map)"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>expand</h4> <pre><a href="../../../../org/gradle/api/file/ContentFilterable.html" title="interface in org.gradle.api.file">ContentFilterable</a>&nbsp;expand(<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,?&gt;&nbsp;properties)</pre> <div class="block"><p>Expands property references in each file as it is copied. More specifically, each file is transformed using Groovy's <a href="http://groovy.codehaus.org/gapi/groovy/text/SimpleTemplateEngine.html?is-external=true" title="class or interface in groovy.text"><code>SimpleTemplateEngine</code></a>. This means you can use simple property references, such as <code>$property</code> or <code>${property}</code> in the file. You can also include arbitrary Groovy code in the file, such as <code>${version ?: 'unknown'}</code> or <code>${classpath*.name.join(' ')}</code></div> <dl><dt><span class="strong">Parameters:</span></dt><dd><code>properties</code> - to implement line based filtering</dd> <dt><span class="strong">Returns:</span></dt><dd>this</dd></dl> </li> </ul> </li> </ul> </li> </ul> </div> </div> <!-- ========= END OF CLASS DATA ========= --> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../index-all.html">Index</a></li> <li><a href="../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../org/gradle/api/file/ConfigurableFileTree.html" title="interface in org.gradle.api.file"><span class="strong">Prev Class</span></a></li> <li><a href="../../../../org/gradle/api/file/CopyProcessingSpec.html" title="interface in org.gradle.api.file"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../../index.html?org/gradle/api/file/ContentFilterable.html" target="_top">Frames</a></li> <li><a href="ContentFilterable.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Constr&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Constr&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
tkmnet/RCRS-ADF
gradle/gradle-2.1/docs/javadoc/org/gradle/api/file/ContentFilterable.html
HTML
bsd-2-clause
15,910
#!/bin/bash BUILD_DIR="." REPO_ROOT="$(git rev-parse --show-toplevel)" SCRIPT_DIR="$REPO_ROOT/scripts/engine" export XML_CATALOG_FILES=~/.openwebrtc/etc/xml/catalog if [[ ! -d $SCRIPT_DIR ]]; then git submodule init git submodule update fi # # Check preconditions: # 1. Check if file releases are missing and download in that case. # check_preconditions() { if [[ ! -d ~/.openwebrtc ]] ; then read -p "OpenWebRTC tools is missing from ~/.openwebrtc, press Enter to build and Ctrl-C to abort" dummy pushd scripts/bootstrap >/dev/null if [[ `uname` == "Darwin" ]]; then local_platform="osx" else local_platform="linux" fi ./bootstrap.sh -r $local_platform || die "Could not install OpenWebRTC tools" popd >/dev/null fi if [[ ! (-e ./openwebrtc-deps-armv7-ios || -e ./openwebrtc-deps-armv7-android \ || -e ./openwebrtc-deps-x86_64-osx || -e ./openwebrtc-deps-x86_64-linux \ || -e ./openwebrtc-deps-x86_64-ios-simulator ) ]]; then read -p "OpenWebRTC dependencies is missing, press Enter to build and Ctrl-C to abort" dummy pushd scripts/dependencies >/dev/null ./build-all.sh $@ || die "Could not build OpenWebRTC dependencies" ./deploy_deps.sh || die "Could not install OpenWebRTC dependencies" popd >/dev/null fi $REPO_ROOT/git_hooks/install_hooks.sh } local_sources_installed(){ true } patch_sources(){ true } local_clean_source(){ true } build(){ local arch=$1 local target_triple=$2 local target target=$(target_from_target_triple $target_triple) || die "Could not get target from $target_triple" local home=$(pwd) local src_dir=$(pwd) local debug=yes if [[ $opt_r == yes ]]; then debug=no fi if [[ ${target_triple} =~ (i386|arm)"-apple-darwin10" || $target_triple == "arm-linux-androideabi" ]]; then if [[ -z $(find ${REPO_ROOT}/build -name Owr-0.1.gir.h) ]]; then die "Missing Owr-0.1.gir.h, build for OS X or Linux first" fi fi ( cd $builddir export CFLAGS="$PLATFORM_CFLAGS -I${src_dir}/openwebrtc-deps-${target}/include -I${src_dir}/framework" if [[ $target_triple == "arm-apple-darwin10" ]]; then local configure_flags="--enable-static --enable-owr-static --disable-shared --disable-introspection" local platform_ldflags="${home}/openwebrtc-deps-armv7-ios/lib/my_environ.o ${home}/openwebrtc-deps-${target}/lib/my_stat.o " local seed_platform_libs="-framework JavaScriptCore" export PLATFORM_GLIB_LIBS="-lffi -lresolv -liconv -lintl " export PLATFORM_GSTREAMER_LIBS="-lgstosxaudio -lgstapplemedia -framework AssetsLibrary -framework CoreMedia -framework CoreVideo -framework AVFoundation -framework Foundation -framework OpenGLES -framework CoreAudio -framework AudioToolbox" export PLATFORM_OWR_GST_PLUGINS_LIBS="-lgstercolorspace" export PLATFORM_CXX_LIBS="-lc++" elif [[ $target_triple == "i386-apple-darwin10" ]]; then local configure_flags="--enable-static --enable-owr-static --disable-shared --disable-introspection" local seed_platform_libs="-framework JavaScriptCore" export PLATFORM_GLIB_LIBS="-lffi -lresolv -liconv -lintl " export PLATFORM_GSTREAMER_LIBS="-framework CoreMedia -framework CoreVideo -framework AVFoundation -framework Foundation -framework OpenGLES -lgstosxaudio -lgstapplemedia -framework AssetsLibrary -framework CoreAudio -framework AudioToolbox" export PLATFORM_CXX_LIBS="-lc++" elif [[ $target_triple == "arm-linux-androideabi" ]]; then local platform_ldflags="-llog -Wl,--allow-multiple-definition " local configure_flags="--disable-static --enable-owr-static --enable-shared --disable-introspection" local seed_platform_libs="-ljavascriptcoregtk-3.0 -licui18n -licuuc -licudata" export PLATFORM_GLIB_LIBS="-lffi -liconv -lintl " export PLATFORM_GSTREAMER_LIBS="-lgstopensles -lOpenSLES -lGLESv2 -lEGL" export PLATFORM_OWR_GST_PLUGINS_LIBS="-lgstandroidvideosrc -lgstercolorspace" export PLATFORM_CXX_LIBS="-L$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a -lgnustl_static -lstdc++" elif [[ $target_triple == "x86_64-apple-darwin" ]]; then local configure_flags="--enable-static --enable-owr-static --enable-shared --enable-gtk-doc" local seed_platform_libs="-framework JavaScriptCore" export PLATFORM_GLIB_LIBS="-lffi -lresolv -liconv -lintl -framework Carbon" export PLATFORM_GSTREAMER_LIBS="-lgstvideoconvert -lgstapplemedia -lgstosxaudio" export PLATFORM_GSTREAMER_LIBS="$PLATFORM_GSTREAMER_LIBS -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework CoreMedia -framework CoreVideo -framework QTKit -framework AVFoundation -framework Foundation -framework VideoToolbox -framework AppKit -framework OpenGL" export PLATFORM_CXX_LIBS="-lc++" elif [[ $target_triple == "x86_64-unknown-linux" ]] ; then local configure_flags="--enable-static --enable-owr-static --enable-shared --enable-gtk-doc" local seed_platform_libs="-ljavascriptcoregtk-3.0 -licui18n -licuuc -licudata" export PLATFORM_GLIB_LIBS="-lpthread -lffi -lrt -ldl -lresolv" export PLATFORM_GSTREAMER_LIBS="-lgstvideoconvert -lgstpulse -lpulse-mainloop-glib -lpulse -lgstvideo4linux2 -lv4l2 -lX11 -lXv -lgstallocators-1.0 -lGLU -lGL" export PLATFORM_CXX_LIBS="-lstdc++" fi # Common exports. # add -DPRINT_RTCP_REPORTS to CFLAGS to see printout of RTCP statistics. export CPPFLAGS=$CFLAGS export LDFLAGS="-L${src_dir}/openwebrtc-deps-${target}/lib -L${src_dir}/openwebrtc-deps-${target}/lib/gstreamer-1.0 -L${src_dir}/openwebrtc-deps-${target}/lib $platform_ldflags" export GLIB_CFLAGS="-isystem ${src_dir}/openwebrtc-deps-${target}/include/glib-2.0" export GLIB_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib -lgio-2.0 -lgmodule-2.0 -lgthread-2.0 -lgobject-2.0 -lglib-2.0 -lz $PLATFORM_GLIB_LIBS" export NICE_CFLAGS="-isystem ${src_dir}/openwebrtc-deps-${target}/include/nice" export NICE_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib -lnice" export ORC_CFLAGS="-I${src_dir}/openwebrtc-deps-${target}/include/orc-0.4" export ORC_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib -lorc-test-0.4 -lorc-0.4" export XML_CFLAGS="-I${src_dir}/openwebrtc-deps-${target}/include/libxml2" export XML_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib -lxml2 -lm" export GSTREAMER_CFLAGS="-isystem ${src_dir}/openwebrtc-deps-${target}/include/gstreamer-1.0 -isystem ${src_dir}/openwebrtc-deps-${target}/include/private-gstreamer" export GSTREAMER_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib -L${src_dir}/openwebrtc-deps-${target}/lib/gstreamer-1.0 -lgstaudiotestsrc -lgstvideotestsrc -lgstcoreelements -lgstalaw -lgstmulaw -lgstopus -lopus -lgstapp -lgstaudioconvert -lgstaudioresample -lgstvolume -lgstvideoconvert -lgstvpx -lvpx -lgstopengl" export GSTREAMER_LIBS="$GSTREAMER_LIBS $PLATFORM_GSTREAMER_LIBS -lgstrtpmanager -lgstrtp -lgstsrtp -lsrtp -lgstvideocrop -lgstvideofilter -lgstvideoparsersbad -lgstvideorate -lgstvideoscale -lgstnice -lgstcontroller-1.0 -lgstpbutils-1.0 -lgstnet-1.0 -lgstrtp-1.0 -lgstgl-1.0 -lgstbadvideo-1.0 -lgstbadbase-1.0" export GSTREAMER_LIBS="$GSTREAMER_LIBS -lgsttag-1.0 -lgstapp-1.0 -lgstaudio-1.0 -lgstvideo-1.0 -lgstcodecparsers-1.0 -lgstbase-1.0 -lgstreamer-1.0" export SEED_CFLAGS="-isystem ${src_dir}/openwebrtc-deps-${target}/include/seed-gtk3 -isystem ${src_dir}/openwebrtc-deps-${target}/include/gobject-introspection-1.0" export SEED_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib/seed-gtk3 -lseed-gtk3 -lseed_sandbox $seed_platform_libs -lgirepository-1.0 -lgirepository-internals $PLATFORM_CXX_LIBS" export ELIB_CFLAGS="-I${src_dir}/openwebrtc-deps-${target}/include/elib" export ELIB_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib -lelib" export ESDP_CFLAGS="-I${src_dir}/openwebrtc-deps-${target}/include/esdp" export ESDP_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib -lesdp" export OPENWEBRTC_GST_PLUGINS_CFLAGS="-I${src_dir}/openwebrtc-deps-${target}/include/plugins" export OPENWEBRTC_GST_PLUGINS_LIBS="-L${src_dir}/openwebrtc-deps-${target}/lib/gstreamer-1.0 -lgsterdtls -lssl -lcrypto -lgstvideorepair -lgstopenh264 -lopenh264 $PLATFORM_OWR_GST_PLUGINS_LIBS $PLATFORM_CXX_LIBS" $REPO_ROOT/autogen.sh \ --prefix=${installdir} \ --host=${target_triple} \ --enable-debug=$debug ${configure_flags} && make && make install ) } . $SCRIPT_DIR/engine.sh
adam-be/openwebrtc
build.sh
Shell
bsd-2-clause
8,993
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>win32.graph.freeimage.FreeImage_Clone</title> <link href="css/style.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > </head> <body bgcolor="#ffffff"> <table border="0" width="100%" bgcolor="#F0F0FF"> <tr> <td>Concept Framework 2.2 documentation</td> <td align="right"><a href="index.html">Contents</a> | <a href="index_fun.html">Index</a></td> </tr> </table> <h2><a href="win32.graph.freeimage.html">win32.graph.freeimage</a>.FreeImage_Clone</h2> <table border="0" cellspacing="0" cellpadding="0" width="500" style="border-style:solid;border-width:1px;border-color:#D0D0D0;"> <tr bgcolor="#f0f0f0"> <td><i>Name</i></td> <td><i>Version</i></td> <td><i>Deprecated</i></td> </tr> <tr bgcolor="#fafafa"> <td><b>FreeImage_Clone</b></td> <td>version 1.0</td> <td>no</td> </tr> </table> <br /> <b>Prototype:</b><br /> <table bgcolor="#F0F0F0" width="100%" style="border-style:solid;border-width:1px;border-color:#D0D0D0;"><tr><td><b>number FreeImage_Clone(number dib)</b></td></tr></table> <br /> <br /> <b>Description:</b><br /> <table width="100%" bgcolor="#FAFAFF" style="border-style:solid;border-width:1px;border-color:#D0D0D0;"> <tr><td> Make an exact reproduction of an existing bitmap, including metadata and attached profile if any. </td></tr> </table> <br /> <b>Returns:</b><br /> Return the cloned image handle. <br /> <br /> <!-- <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html40" alt="Valid HTML 4.0 Transitional" height="31" width="88" border="0"></a> <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" border="0"/> </a> </p> --> <table bgcolor="#F0F0F0" width="100%"><tr><td>Documented by Eduard Suica, generation time: Sun Jan 27 18:15:20 2013 GMT</td><td align="right">(c)2013 <a href="http://www.devronium.com">Devronium Applications</a></td></tr></table> </body> </html>
Devronium/ConceptApplicationServer
core/server/Samples/CIDE/Help/win32.graph.freeimage.FreeImage_Clone.html
HTML
bsd-2-clause
2,247
# -*- coding: utf-8 -*- """ Barycenters =========== This example shows three methods to compute barycenters of time series. For an overview over the available methods see the :mod:`tslearn.barycenters` module. *tslearn* provides three methods for calculating barycenters for a given set of time series: * *Euclidean barycenter* is simply the arithmetic mean for each individual point in time, minimizing the summed euclidean distance for each of them. As can be seen below, it is very different from the DTW-based methods and may often be inappropriate. However, it is the fastest of the methods shown. * *DTW Barycenter Averaging (DBA)* is an iteratively refined barycenter, starting out with a (potentially) bad candidate and improving it until convergence criteria are met. The optimization can be accomplished with (a) expectation-maximization [1] and (b) stochastic subgradient descent [2]. Empirically, the latter "is [often] more stable and finds better solutions in shorter time" [2]. * *Soft-DTW barycenter* uses a differentiable loss function to iteratively find a barycenter [3]. The method itself and the parameter :math:`\\gamma=1.0` is described in more detail in the section on :ref:`DTW<dtw>`. There is also a dedicated :ref:`example<sphx_glr_auto_examples_clustering_plot_barycenter_interpolate.py>` available. [1] F. Petitjean, A. Ketterlin & P. Gancarski. A global averaging method for dynamic time warping, with applications to clustering. Pattern Recognition, Elsevier, 2011, Vol. 44, Num. 3, pp. 678-693. [2] D. Schultz & B. Jain. Nonsmooth Analysis and Subgradient Methods for Averaging in Dynamic Time Warping Spaces. Pattern Recognition, 74, 340-358. [3] M. Cuturi & M. Blondel. Soft-DTW: a Differentiable Loss Function for Time-Series. ICML 2017. """ # Author: Romain Tavenard, Felix Divo # License: BSD 3 clause import numpy import matplotlib.pyplot as plt from tslearn.barycenters import \ euclidean_barycenter, \ dtw_barycenter_averaging, \ dtw_barycenter_averaging_subgradient, \ softdtw_barycenter from tslearn.datasets import CachedDatasets # fetch the example data set numpy.random.seed(0) X_train, y_train, _, _ = CachedDatasets().load_dataset("Trace") X = X_train[y_train == 2] length_of_sequence = X.shape[1] def plot_helper(barycenter): # plot all points of the data set for series in X: plt.plot(series.ravel(), "k-", alpha=.2) # plot the given barycenter of them plt.plot(barycenter.ravel(), "r-", linewidth=2) # plot the four variants with the same number of iterations and a tolerance of # 1e-3 where applicable ax1 = plt.subplot(4, 1, 1) plt.title("Euclidean barycenter") plot_helper(euclidean_barycenter(X)) plt.subplot(4, 1, 2, sharex=ax1) plt.title("DBA (vectorized version of Petitjean's EM)") plot_helper(dtw_barycenter_averaging(X, max_iter=50, tol=1e-3)) plt.subplot(4, 1, 3, sharex=ax1) plt.title("DBA (subgradient descent approach)") plot_helper(dtw_barycenter_averaging_subgradient(X, max_iter=50, tol=1e-3)) plt.subplot(4, 1, 4, sharex=ax1) plt.title("Soft-DTW barycenter ($\gamma$=1.0)") plot_helper(softdtw_barycenter(X, gamma=1., max_iter=50, tol=1e-3)) # clip the axes for better readability ax1.set_xlim([0, length_of_sequence]) # show the plot(s) plt.tight_layout() plt.show()
rtavenar/tslearn
tslearn/docs/examples/clustering/plot_barycenters.py
Python
bsd-2-clause
3,323
import pump import pump_bfd class BFDSinkEx(pump_bfd.BFDSink): def __init__(self, opts, spec, source_bucket, source_node, source_map, sink_map, ctl, cur): super(pump_bfd.BFDSink, self).__init__(opts, spec, source_bucket, source_node, source_map, sink_map, ctl, cur) self.mode = getattr(opts, "mode", "diff") self.init_worker(pump_bfd.BFDSink.run) @staticmethod def check_spec(source_bucket, source_node, opts, spec, cur): pump.Sink.check_spec(source_bucket, source_node, opts, spec, cur) seqno, dep, faillover_log, snapshot_markers = pump_bfd.BFD.find_seqno(opts, spec, source_bucket['name'], source_node['hostname'], getattr(opts, "mode", "diff")) if 'seqno' in cur: cur['seqno'][(source_bucket['name'], source_node['hostname'])] = seqno else: cur['seqno'] = {(source_bucket['name'], source_node['hostname']): seqno} if 'failoverlog' in cur: cur['failoverlog'][(source_bucket['name'], source_node['hostname'])] = faillover_log else: cur['failoverlog'] = {(source_bucket['name'], source_node['hostname']): faillover_log} if 'snapshot' in cur: cur['snapshot'][(source_bucket['name'], source_node['hostname'])] = snapshot_markers else: cur['snapshot'] = {(source_bucket['name'], source_node['hostname']): snapshot_markers}
TOTVS/mdmpublic
couchbase-cli/lib/python/pump_bfd2.py
Python
bsd-2-clause
1,621
FROM zefciu/python-base MAINTAINER Pylabs <pylabs@allegro.pl> RUN pip install nose py3dns requests ADD test test ADD runtests.sh runtests.sh CMD bin/sh runtests.sh
zefciu/django-powerdns-dnssec
integration-tests/Dockerfile
Dockerfile
bsd-2-clause
164
/* * Copyright (C) 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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 MediaRemoteControls_h #define MediaRemoteControls_h #if ENABLE(MEDIA_SESSION) #include "EventTarget.h" #include <wtf/RefCounted.h> namespace WebCore { class MediaSession; class MediaRemoteControls : public RefCounted<MediaRemoteControls>, public EventTargetWithInlineData { public: static Ref<MediaRemoteControls> create(ScriptExecutionContext& context, MediaSession* session = nullptr) { return adoptRef(*new MediaRemoteControls(context, session)); } bool previousTrackEnabled() const { return m_previousTrackEnabled; } void setPreviousTrackEnabled(bool); bool nextTrackEnabled() const { return m_nextTrackEnabled; } void setNextTrackEnabled(bool); using RefCounted<MediaRemoteControls>::ref; using RefCounted<MediaRemoteControls>::deref; void clearSession(); virtual ~MediaRemoteControls(); EventTargetInterface eventTargetInterface() const override { return MediaRemoteControlsEventTargetInterfaceType; } ScriptExecutionContext* scriptExecutionContext() const override { return &m_scriptExecutionContext; } private: MediaRemoteControls(ScriptExecutionContext&, MediaSession*); ScriptExecutionContext& m_scriptExecutionContext; bool m_previousTrackEnabled { false }; bool m_nextTrackEnabled { false }; MediaSession* m_session { nullptr }; void refEventTarget() final { ref(); } void derefEventTarget() final { deref(); } }; } // namespace WebCore #endif /* ENABLE(MEDIA_SESSION) */ #endif /* MediaRemoteControls_h */
applesrc/WebCore
Modules/mediasession/MediaRemoteControls.h
C
bsd-2-clause
2,866
namespace Humidifier.Lambda { using System.Collections.Generic; using FunctionTypes; public class Function : Humidifier.Resource { public static class Attributes { public static string Arn = "Arn" ; } public override string AWSTypeName { get { return @"AWS::Lambda::Function"; } } /// <summary> /// Code /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code /// Required: True /// UpdateType: Mutable /// Type: Code /// </summary> public Code Code { get; set; } /// <summary> /// DeadLetterConfig /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-deadletterconfig /// Required: False /// UpdateType: Mutable /// Type: DeadLetterConfig /// </summary> public DeadLetterConfig DeadLetterConfig { get; set; } /// <summary> /// Description /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-description /// Required: False /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic Description { get; set; } /// <summary> /// Environment /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-environment /// Required: False /// UpdateType: Mutable /// Type: Environment /// </summary> public Environment Environment { get; set; } /// <summary> /// FunctionName /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-functionname /// Required: False /// UpdateType: Immutable /// PrimitiveType: String /// </summary> public dynamic FunctionName { get; set; } /// <summary> /// Handler /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-handler /// Required: True /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic Handler { get; set; } /// <summary> /// KmsKeyArn /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-kmskeyarn /// Required: False /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic KmsKeyArn { get; set; } /// <summary> /// Layers /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-layers /// Required: False /// UpdateType: Mutable /// Type: List /// PrimitiveItemType: String /// </summary> public dynamic Layers { get; set; } /// <summary> /// MemorySize /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-memorysize /// Required: False /// UpdateType: Mutable /// PrimitiveType: Integer /// </summary> public dynamic MemorySize { get; set; } /// <summary> /// ReservedConcurrentExecutions /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-reservedconcurrentexecutions /// Required: False /// UpdateType: Mutable /// PrimitiveType: Integer /// </summary> public dynamic ReservedConcurrentExecutions { get; set; } /// <summary> /// Role /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-role /// Required: True /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic Role { get; set; } /// <summary> /// Runtime /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-runtime /// Required: True /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic Runtime { get; set; } /// <summary> /// Tags /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tags /// Required: False /// UpdateType: Mutable /// Type: List /// ItemType: Tag /// </summary> public List<Tag> Tags { get; set; } /// <summary> /// Timeout /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-timeout /// Required: False /// UpdateType: Mutable /// PrimitiveType: Integer /// </summary> public dynamic Timeout { get; set; } /// <summary> /// TracingConfig /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tracingconfig /// Required: False /// UpdateType: Mutable /// Type: TracingConfig /// </summary> public TracingConfig TracingConfig { get; set; } /// <summary> /// VpcConfig /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-vpcconfig /// Required: False /// UpdateType: Mutable /// Type: VpcConfig /// </summary> public VpcConfig VpcConfig { get; set; } } namespace FunctionTypes { public class VpcConfig { /// <summary> /// SecurityGroupIds /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html#cfn-lambda-function-vpcconfig-securitygroupids /// Required: True /// UpdateType: Mutable /// Type: List /// PrimitiveItemType: String /// </summary> public dynamic SecurityGroupIds { get; set; } /// <summary> /// SubnetIds /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html#cfn-lambda-function-vpcconfig-subnetids /// Required: True /// UpdateType: Mutable /// Type: List /// PrimitiveItemType: String /// </summary> public dynamic SubnetIds { get; set; } } public class DeadLetterConfig { /// <summary> /// TargetArn /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-deadletterconfig.html#cfn-lambda-function-deadletterconfig-targetarn /// Required: False /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic TargetArn { get; set; } } public class Code { /// <summary> /// S3Bucket /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3bucket /// Required: False /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic S3Bucket { get; set; } /// <summary> /// S3Key /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3key /// Required: False /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic S3Key { get; set; } /// <summary> /// S3ObjectVersion /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3objectversion /// Required: False /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic S3ObjectVersion { get; set; } /// <summary> /// ZipFile /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-zipfile /// Required: False /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic ZipFile { get; set; } } public class TracingConfig { /// <summary> /// Mode /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-tracingconfig.html#cfn-lambda-function-tracingconfig-mode /// Required: False /// UpdateType: Mutable /// PrimitiveType: String /// </summary> public dynamic Mode { get; set; } } public class Environment { /// <summary> /// Variables /// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html#cfn-lambda-function-environment-variables /// Required: False /// UpdateType: Mutable /// Type: Map /// PrimitiveItemType: String /// </summary> public Dictionary<string, dynamic> Variables { get; set; } } } }
jakejscott/Humidifier
src/Humidifier/Lambda/Function.cs
C#
bsd-2-clause
11,209
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -Wno-deprecated-declarations // RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify -fms-extensions %s -Wno-deprecated-declarations typedef struct _GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; } GUID; namespace { // cl.exe's behavior with merging uuid attributes is a bit erratic: // * In []-style attributes, a single [] list must not list a duplicate uuid // (even if it's the same uuid), and only a single declaration of a class // must have a uuid else the compiler errors out (even if two declarations of // a class have the same uuid). // * For __declspec(uuid(...)), it's ok if several declarations of a class have // an uuid, as long as it's the same uuid each time. If uuids on declarations // don't match, the compiler errors out. // * If there are several __declspec(uuid(...))s on one declaration, the // compiler only warns about this and uses the last uuid. It even warns if // the uuids are the same. // clang-cl implements the following simpler (but largely compatible) behavior // instead: // * [] and __declspec uuids have the same behavior. // * If there are several uuids on a class (no matter if on the same decl or // on several decls), it is an error if they don't match. // * Having several uuids that match is ok. // Both cl and clang-cl accept this: class __declspec(uuid("000000A0-0000-0000-C000-000000000049")) C1; class __declspec(uuid("000000a0-0000-0000-c000-000000000049")) C1; class __declspec(uuid("{000000a0-0000-0000-C000-000000000049}")) C1; class __declspec(uuid("000000A0-0000-0000-C000-000000000049")) C1 {}; // Both cl and clang-cl error out on this: // expected-note@+1 2{{previous uuid specified here}} class __declspec(uuid("000000A0-0000-0000-C000-000000000049")) C2; // expected-error@+1 {{uuid does not match previous declaration}} class __declspec(uuid("110000A0-0000-0000-C000-000000000049")) C2; // expected-error@+1 {{uuid does not match previous declaration}} class __declspec(uuid("220000A0-0000-0000-C000-000000000049")) C2 {}; // expected-note@+1 {{previous uuid specified here}} class __declspec(uuid("000000A0-0000-0000-C000-000000000049")) C2_2; class C2_2; // expected-error@+1 {{uuid does not match previous declaration}} class __declspec(uuid("110000A0-0000-0000-C000-000000000049")) C2_2; // clang-cl accepts this, but cl errors out: [uuid("000000A0-0000-0000-C000-000000000049")] class C3; [uuid("000000A0-0000-0000-C000-000000000049")] class C3; [uuid("000000A0-0000-0000-C000-000000000049")] class C3 {}; // Both cl and clang-cl error out on this (but for different reasons): // expected-note@+1 2{{previous uuid specified here}} [uuid("000000A0-0000-0000-C000-000000000049")] class C4; // expected-error@+1 {{uuid does not match previous declaration}} [uuid("110000A0-0000-0000-C000-000000000049")] class C4; // expected-error@+1 {{uuid does not match previous declaration}} [uuid("220000A0-0000-0000-C000-000000000049")] class C4 {}; // Both cl and clang-cl error out on this: // expected-error@+1 {{uuid does not match previous declaration}} class __declspec(uuid("000000A0-0000-0000-C000-000000000049")) // expected-note@+1 {{previous uuid specified here}} __declspec(uuid("110000A0-0000-0000-C000-000000000049")) C5; // expected-error@+1 {{uuid does not match previous declaration}} [uuid("000000A0-0000-0000-C000-000000000049"), // expected-note@+1 {{previous uuid specified here}} uuid("110000A0-0000-0000-C000-000000000049")] class C6; // cl doesn't diagnose having one uuid each as []-style attributes and as // __declspec, even if the uuids differ. clang-cl errors if they differ. [uuid("000000A0-0000-0000-C000-000000000049")] class __declspec(uuid("000000A0-0000-0000-C000-000000000049")) C7; // expected-note@+1 {{previous uuid specified here}} [uuid("000000A0-0000-0000-C000-000000000049")] // expected-error@+1 {{uuid does not match previous declaration}} class __declspec(uuid("110000A0-0000-0000-C000-000000000049")) C8; // cl warns on this, but clang-cl is fine with it (which is consistent with // e.g. specifying __multiple_inheritance several times, which cl accepts // without warning too). class __declspec(uuid("000000A0-0000-0000-C000-000000000049")) __declspec(uuid("000000A0-0000-0000-C000-000000000049")) C9; // cl errors out on this, but clang-cl is fine with it (to be consistent with // the previous case). [uuid("000000A0-0000-0000-C000-000000000049"), uuid("000000A0-0000-0000-C000-000000000049")] class C10; template <const GUID* p> void F1() { // Regression test for PR24986. The given GUID should just work as a pointer. const GUID* q = p; } void F2() { // The UUID should work for a non-type template parameter. F1<&__uuidof(C1)>(); } } // Test class/struct redeclaration where the subsequent // declaration has a uuid attribute struct X{}; struct __declspec(uuid("00000000-0000-0000-0000-000000000000")) X;
epiqc/ScaffCC
clang/test/SemaCXX/ms-uuid.cpp
C++
bsd-2-clause
4,986
namespace HikingPathFinder.Model { /// <summary> /// Photo infos and photo data /// </summary> public class Photo { /// <summary> /// Reference infos for photo /// </summary> public PhotoRef Ref { get; set; } /// <summary> /// Actual JPEG data of photo /// </summary> public byte[] JPEGData { get; set; } /// <summary> /// Returns a printable representation of this object /// </summary> /// <returns>printable text</returns> public override string ToString() { return string.Format( "{0}, Data={1} bytes", this.Ref.ToString(), this.JPEGData.Length); } } }
vividos/HikingPathFinder
src/Shared/Model/Photo.cs
C#
bsd-2-clause
766
// This code contains NVIDIA Confidential Information and is disclosed to you // under a form of NVIDIA software license agreement provided separately to you. // // Notice // NVIDIA Corporation and its licensors retain all intellectual property and // proprietary rights in and to this software and related documentation and // any modifications thereto. Any use, reproduction, disclosure, or // distribution of this software and related documentation without an express // license agreement from NVIDIA Corporation is strictly prohibited. // // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. // // Information and code furnished is believed to be accurate and reliable. // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such // information or for any infringement of patents or other rights of third parties that may // result from its use. No license is granted by implication or otherwise under any patent // or patent rights of NVIDIA Corporation. Details are subject to change without notice. // This code supersedes and replaces all information previously supplied. // NVIDIA Corporation products are not authorized for use as critical // components in life support devices or systems without express written approval of // NVIDIA Corporation. // // Copyright (c) 2008-2012 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "ExtPrismaticJoint.h" #include "ExtConstraintHelper.h" #include "CmRenderOutput.h" #include "CmVisualization.h" #include "CmSerialAlignment.h" #ifdef PX_PS3 #include "PS3/ExtPrismaticJointSpu.h" #endif using namespace physx; using namespace Ext; PxPrismaticJoint* physx::PxPrismaticJointCreate(PxPhysics& physics, PxRigidActor* actor0, const PxTransform& localFrame0, PxRigidActor* actor1, const PxTransform& localFrame1) { PX_CHECK_AND_RETURN_NULL(localFrame0.isValid(), "PxPrismaticJointCreate: local frame 0 is not a valid transform"); PX_CHECK_AND_RETURN_NULL(localFrame1.isValid(), "PxPrismaticJointCreate: local frame 1 is not a valid transform"); PX_CHECK_AND_RETURN_NULL(actor0 && actor0->is<PxRigidBody>() || actor1 && actor1->is<PxRigidBody>(), "PxPrismaticJointCreate: at least one actor must be dynamic"); PrismaticJoint* j = PX_NEW(PrismaticJoint)(physics.getTolerancesScale(), actor0, localFrame0, actor1, localFrame1); if(j->attach(physics, actor0, actor1)) return j; PX_DELETE(j); return NULL; } void PrismaticJoint::setProjectionAngularTolerance(PxReal tolerance) { PX_CHECK_AND_RETURN(PxIsFinite(tolerance) && tolerance >=0 && tolerance <= PxPi, "PxPrismaticJoint::setProjectionAngularTolerance: invalid parameter"); data().projectionAngularTolerance = tolerance; markDirty(); } PxReal PrismaticJoint::getProjectionAngularTolerance() const { return data().projectionAngularTolerance; } void PrismaticJoint::setProjectionLinearTolerance(PxReal tolerance) { PX_CHECK_AND_RETURN(PxIsFinite(tolerance), "PxPrismaticJoint::setProjectionLinearTolerance: invalid parameter"); data().projectionLinearTolerance = tolerance; markDirty(); } PxReal PrismaticJoint::getProjectionLinearTolerance() const { return data().projectionLinearTolerance; } PxPrismaticJointFlags PrismaticJoint::getPrismaticJointFlags(void) const { return data().jointFlags; } void PrismaticJoint::setPrismaticJointFlags(PxPrismaticJointFlags flags) { data().jointFlags = flags; markDirty(); } void PrismaticJoint::setPrismaticJointFlag(PxPrismaticJointFlag::Enum flag, bool value) { if(value) data().jointFlags |= flag; else data().jointFlags &= ~flag; markDirty(); } PxJointLimitPair PrismaticJoint::getLimit() const { return data().limit; } void PrismaticJoint::setLimit(const PxJointLimitPair& limit) { PX_CHECK_AND_RETURN(limit.isValid(), "PxPrismaticJoint::setLimit: invalid parameter"); data().limit = limit; } namespace { void PrismaticJointVisualize(PxConstraintVisualizer& viz, const void* constantBlock, const PxTransform& body0Transform, const PxTransform& body1Transform, PxU32 flags) { const PrismaticJointData& data = *reinterpret_cast<const PrismaticJointData*>(constantBlock); const PxTransform& t0 = body0Transform * data.c2b[0]; const PxTransform& t1 = body1Transform * data.c2b[1]; viz.visualizeJointFrames(t0, t1); PxVec3 axis = t0.rotate(PxVec3(1,0,0)); PxReal ordinate = axis.dot(t0.transformInv(t1.p)-t0.p); if(data.jointFlags & PxPrismaticJointFlag::eLIMIT_ENABLED) { viz.visualizeLinearLimit(t0, t1, data.limit.lower, ordinate < data.limit.lower + data.limit.contactDistance); viz.visualizeLinearLimit(t0, t1, data.limit.upper, ordinate > data.limit.upper - data.limit.contactDistance); } } void PrismaticJointProject(const void* constantBlock, PxTransform& bodyAToWorld, PxTransform& bodyBToWorld, bool projectToA) { using namespace joint; const PrismaticJointData& data = *reinterpret_cast<const PrismaticJointData*>(constantBlock); PxTransform cA2w, cB2w, cB2cA, projected; computeDerived(data, bodyAToWorld, bodyBToWorld, cA2w, cB2w, cB2cA); PxVec3 v(0,cB2cA.p.y,cB2cA.p.z); bool linearTrunc, angularTrunc; projected.p = truncateLinear(v, data.projectionLinearTolerance, linearTrunc); projected.q = truncateAngular(cB2cA.q, PxSin(data.projectionAngularTolerance/2), PxCos(data.projectionAngularTolerance/2), angularTrunc); if(linearTrunc || angularTrunc) { projected.p.x = cB2cA.p.x; projectTransforms(bodyAToWorld, bodyBToWorld, cA2w, cB2w, projected, data, projectToA); } } } bool Ext::PrismaticJoint::attach(PxPhysics &physics, PxRigidActor* actor0, PxRigidActor* actor1) { mPxConstraint = physics.createConstraint(actor0, actor1, *this, sShaders, sizeof(PrismaticJointData)); return mPxConstraint!=NULL; } // PX_SERIALIZATION BEGIN_FIELDS(PrismaticJoint) // DEFINE_STATIC_ARRAY(PrismaticJoint, mData, PxField::eBYTE, sizeof(PrismaticJointData), Ps::F_SERIALIZE), END_FIELDS(PrismaticJoint) void PrismaticJoint::exportExtraData(PxSerialStream& stream) { if(mData) { Cm::alignStream(stream, PX_SERIAL_DEFAULT_ALIGN_EXTRA_DATA_WIP); stream.storeBuffer(mData, sizeof(PrismaticJointData)); } } char* PrismaticJoint::importExtraData(char* address, PxU32& totalPadding) { if(mData) { address = Cm::alignStream(address, totalPadding, PX_SERIAL_DEFAULT_ALIGN_EXTRA_DATA_WIP); mData = reinterpret_cast<PrismaticJointData*>(address); address += sizeof(PrismaticJointData); } return address; } bool PrismaticJoint::resolvePointers(PxRefResolver& v, void* context) { PrismaticJointT::resolvePointers(v, context); setPxConstraint(resolveConstraintPtr(v, getPxConstraint(), getConnector(), sShaders)); return true; } //~PX_SERIALIZATION #ifdef PX_PS3 PxConstraintShaderTable Ext::PrismaticJoint::sShaders = { Ext::PrismaticJointSolverPrep, ExtPrismaticJointSpu, EXTPRISMATICJOINTSPU_SIZE, PrismaticJointProject, PrismaticJointVisualize }; #else PxConstraintShaderTable Ext::PrismaticJoint::sShaders = { Ext::PrismaticJointSolverPrep, 0, 0, PrismaticJointProject, PrismaticJointVisualize }; #endif
nmovshov/ARSS_win
extern/PhysX/v3.2.0_win/Source/PhysXExtensions/src/ExtPrismaticJoint.cpp
C++
bsd-2-clause
7,702
/* This file is a part of libcds - Concurrent Data Structures library Version: 2.0.0 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2014 Distributed under the BSD license (see accompanying file license.txt) Source code repo: http://github.com/khizmax/libcds/ Download: http://sourceforge.net/projects/libcds/files/ */ #include "list/hdr_michael_kv.h" #include <cds/urcu/general_threaded.h> #include <cds/container/michael_kvlist_rcu.h> namespace ordlist { namespace { typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_type; struct RCU_GPT_cmp_traits: public cc::michael_list::traits { typedef MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare; }; } void MichaelKVListTestHeader::RCU_GPT_cmp() { // traits-based version typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_cmp_traits > list; test_rcu< list >(); // option-based version typedef cc::MichaelKVList< rcu_type, key_type, value_type, cc::michael_list::make_traits< cc::opt::compare< cmp<key_type> > >::type > opt_list; test_rcu< opt_list >(); } namespace { struct RCU_GPT_less_traits : public cc::michael_list::traits { typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less; }; } void MichaelKVListTestHeader::RCU_GPT_less() { // traits-based version typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_less_traits > list; test_rcu< list >(); // option-based version typedef cc::MichaelKVList< rcu_type, key_type, value_type, cc::michael_list::make_traits< cc::opt::less< lt<key_type> > >::type > opt_list; test_rcu< opt_list >(); } namespace { struct RCU_GPT_cmpmix_traits : public cc::michael_list::traits { typedef MichaelKVListTestHeader::cmp<MichaelKVListTestHeader::key_type> compare; typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less; }; } void MichaelKVListTestHeader::RCU_GPT_cmpmix() { // traits-based version typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_cmpmix_traits > list; test_rcu< list >(); // option-based version typedef cc::MichaelKVList< rcu_type, key_type, value_type, cc::michael_list::make_traits< cc::opt::compare< cmp<key_type> > ,cc::opt::less< lt<key_type> > >::type > opt_list; test_rcu< opt_list >(); } namespace { struct RCU_GPT_ic_traits : public cc::michael_list::traits { typedef MichaelKVListTestHeader::lt<MichaelKVListTestHeader::key_type> less; typedef cds::atomicity::item_counter item_counter; }; } void MichaelKVListTestHeader::RCU_GPT_ic() { // traits-based version typedef cc::MichaelKVList< rcu_type, key_type, value_type, RCU_GPT_ic_traits > list; test_rcu< list >(); // option-based version typedef cc::MichaelKVList< rcu_type, key_type, value_type, cc::michael_list::make_traits< cc::opt::less< lt<key_type> > ,cc::opt::item_counter< cds::atomicity::item_counter > >::type > opt_list; test_rcu< opt_list >(); } } // namespace ordlist
Rapotkinnik/libcds
tests/test-hdr/list/hdr_michael_kv_rcu_gpt.cpp
C++
bsd-2-clause
3,606
/*============================================================================ CMake - Cross Platform Makefile Generator Copyright 2013 Stephen Kelly <steveire@gmail.com> Distributed under the OSI-approved BSD License (the "License"); see accompanying file Copyright.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ #ifndef cmExportInstallFileGenerator_h #define cmExportInstallFileGenerator_h #include "cmExportFileGenerator.h" class cmInstallExportGenerator; class cmInstallTargetGenerator; class cmExportTryCompileFileGenerator: public cmExportFileGenerator { public: /** Set the list of targets to export. */ void SetExports(const std::vector<cmTarget const*> &exports) { this->Exports = exports; } void SetConfig(const char *config) { this->Config = config; } protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream&, const char*, std::string const&, std::vector<std::string>&) {} virtual void HandleMissingTarget(std::string&, std::vector<std::string>&, cmMakefile*, cmTarget*, cmTarget*) {} void PopulateProperties(cmTarget const* target, ImportPropertyMap& properties, std::set<cmTarget const*> &emitted); std::string InstallNameDir(cmTarget* target, const std::string& config); private: std::string FindTargets(const char *prop, cmTarget const* tgt, std::set<cmTarget const*> &emitted); std::vector<cmTarget const*> Exports; const char *Config; }; #endif
unix1986/universe
tool/cmake-3.0.2/Source/cmExportTryCompileFileGenerator.h
C
bsd-2-clause
2,107
#include <algorithm> #include <cassert> #include <cstdio> #include <iostream> #include <sstream> #include <string> #include <vector> #include <deque> using namespace std; class RecurrenceRelation { public: int retval(int x) { if (x < 0) return (10-((-x)%10))%10; else return x%10; } int moduloTen(vector <int> coef, vector <int> initial, int N) { int n = initial.size(); if (N < n) return retval(initial[N]); deque<int> vals(initial.begin(), initial.end()); int val = 0; for (; n<=N; ++n) { val = 0; for (int i=0; i<(int)coef.size(); ++i) val += retval(coef[i]*vals[i]); vals.pop_front(); vals.push_back(val); } return retval(val); } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); if ((Case == -1) || (Case == 5)) test_case_5(); if ((Case == -1) || (Case == 6)) test_case_6(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { int Arr0[] = {2,1}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = {9,7}; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); int Arg2 = 6; int Arg3 = 5; verify_case(0, Arg3, moduloTen(Arg0, Arg1, Arg2)); } void test_case_1() { int Arr0[] = {1,1}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = {0,1}; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); int Arg2 = 9; int Arg3 = 4; verify_case(1, Arg3, moduloTen(Arg0, Arg1, Arg2)); } void test_case_2() { int Arr0[] = {2}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = {1}; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); int Arg2 = 20; int Arg3 = 6; verify_case(2, Arg3, moduloTen(Arg0, Arg1, Arg2)); } void test_case_3() { int Arr0[] = {2}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = {1}; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); int Arg2 = 64; int Arg3 = 6; verify_case(3, Arg3, moduloTen(Arg0, Arg1, Arg2)); } void test_case_4() { int Arr0[] = {25,143}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = {0,0}; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); int Arg2 = 100000; int Arg3 = 0; verify_case(4, Arg3, moduloTen(Arg0, Arg1, Arg2)); } void test_case_5() { int Arr0[] = {9,8,7,6,5,4,3,2,1,0}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = {1,2,3,4,5,6,7,8,9,10}; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); int Arg2 = 654; int Arg3 = 5; verify_case(5, Arg3, moduloTen(Arg0, Arg1, Arg2)); } void test_case_6() { int Arr0[] = {901,492,100}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = {-6,-15,-39}; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); int Arg2 = 0; int Arg3 = 4; verify_case(6, Arg3, moduloTen(Arg0, Arg1, Arg2)); } // END CUT HERE }; // BEGIN CUT HERE int main() { RecurrenceRelation ___test; ___test.run_test(-1); } // END CUT HERE
ibudiselic/contest-problem-solutions
tc 160+/RecurrenceRelation.cpp
C++
bsd-2-clause
3,828
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <style lang="css"> body { background-color: #F4F4F4; color: #333; font-family: Segoe UI,Tahoma,Arial,Verdana,sans-serif; } p#intro { font-family: Cambria,serif; font-size: 1.1em; color: #444; } p#intro a { color: #444; } p#intro a:visited { color: #444; } .block { background-color: #e0e0e0; padding: 16px; margin: 20px; } p.case_text_block { border-radius: 10px; border: 1px solid #aaa; padding: 16px; margin: 4px 20px; color: #444; } p.case_desc { } p.case_expect { } p.case_outcome { } p.case_closing_beh { } pre.http_dump { font-family: Consolas, "Courier New", monospace; font-size: 0.8em; color: #333; border-radius: 10px; border: 1px solid #aaa; padding: 16px; margin: 4px 20px; } span.case_pickle { font-family: Consolas, "Courier New", monospace; font-size: 0.7em; color: #000; } p#case_result,p#close_result { border-radius: 10px; background-color: #e8e2d1; padding: 20px; margin: 20px; } h1 { margin-left: 60px; } h2 { margin-left: 30px; } h3 { margin-left: 50px; } a.up { float: right; border-radius: 16px; margin-top: 16px; margin-bottom: 10px; margin-right: 30px; padding-left: 10px; padding-right: 10px; padding-bottom: 2px; padding-top: 2px; background-color: #666; color: #fff; text-decoration: none; font-size: 0.8em; } a.up:visited { } a.up:hover { background-color: #028ec9; } </style> <style lang="css"> p.case { color: #fff; border-radius: 10px; padding: 20px; margin: 12px 20px; font-size: 1.2em; } p.case_ok { background-color: #0a0; } p.case_non_strict, p.case_no_close { background-color: #9a0; } p.case_info { background-color: #4095BF; } p.case_failed { background-color: #900; } table { border-collapse: collapse; border-spacing: 0px; margin-left: 80px; margin-bottom: 12px; margin-top: 0px; } td { margin: 0; font-size: 0.8em; border: 1px #fff solid; padding-top: 6px; padding-bottom: 6px; padding-left: 16px; padding-right: 16px; text-align: right; } td.right { text-align: right; } td.left { text-align: left; } tr.stats_header { color: #eee; background-color: #000; } tr.stats_row { color: #000; background-color: #fc3; } tr.stats_total { color: #fff; background-color: #888; } div#wirelog { margin-top: 20px; margin-bottom: 80px; } pre.wirelog_rx_octets {color: #aaa; margin: 0; background-color: #060; padding: 2px;} pre.wirelog_tx_octets {color: #aaa; margin: 0; background-color: #600; padding: 2px;} pre.wirelog_tx_octets_sync {color: #aaa; margin: 0; background-color: #606; padding: 2px;} pre.wirelog_rx_frame {color: #fff; margin: 0; background-color: #0a0; padding: 2px;} pre.wirelog_tx_frame {color: #fff; margin: 0; background-color: #a00; padding: 2px;} pre.wirelog_tx_frame_sync {color: #fff; margin: 0; background-color: #a0a; padding: 2px;} pre.wirelog_delay {color: #fff; margin: 0; background-color: #000; padding: 2px;} pre.wirelog_kill_after {color: #fff; margin: 0; background-color: #000; padding: 2px;} pre.wirelog_tcp_closed_by_me {color: #fff; margin: 0; background-color: #008; padding: 2px;} pre.wirelog_tcp_closed_by_peer {color: #fff; margin: 0; background-color: #000; padding: 2px;} </style> </head> <body> <a name="top"></a> <br/> <center><a href="http://autobahn.ws/testsuite" title="Autobahn WebSockets Testsuite"><img src="http://autobahn.ws/static/img/ws_protocol_test_report.png" border="0" width="820" height="46" alt="Autobahn WebSockets Testsuite Report"></img></a></center> <center><a href="http://autobahn.ws" title="Autobahn WebSockets"> <img src="http://autobahn.ws/static/img/ws_protocol_test_report_autobahn.png" border="0" width="300" height="68" alt="Autobahn WebSockets"> </img></a></center> <br/> <p class="case case_ok">snacka - <span style="font-size: 1.3em;"><b>Case 7.7.4</b></span> : Pass - <span style="font-size: 0.9em;"><b>1</b> ms @ 2013-09-26T21:20:12Z</a></p> <p class="case_text_block case_desc"><b>Case Description</b><br/><br/>Send close with valid close code 1003</p> <p class="case_text_block case_expect"><b>Case Expectation</b><br/><br/>Clean close with normal or echoed code</p> <p class="case_text_block case_outcome"> <b>Case Outcome</b><br/><br/>Actual events match at least one expected.<br/><br/> <i>Expected:</i><br/><span class="case_pickle">{'OK': []}</span><br/><br/> <i>Observed:</i><br><span class="case_pickle">[]</span> </p> <p class="case_text_block case_closing_beh"><b>Case Closing Behavior</b><br/><br/>Connection was properly closed (OK)</p> <br/><hr/> <h2>Opening Handshake</h2> <pre class="http_dump">GET /runCase?case=222&agent=snacka HTTP/1.1 Host: localhost:9001 Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key:x3JJHMbDL1EzLkh9GBhXDw== Sec-WebSocket-Version: 13</pre> <pre class="http_dump">HTTP/1.1 101 Switching Protocols Server: AutobahnTestSuite/0.5.5-0.5.14 Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=</pre> <br/><hr/> <h2>Closing Behavior</h2> <table> <tr class="stats_header"><td>Key</td><td class="left">Value</td><td class="left">Description</td></tr> <tr class="stats_row"><td>isServer</td><td class="left">True</td><td class="left">True, iff I (the fuzzer) am a server, and the peer is a client.</td></tr> <tr class="stats_row"><td>closedByMe</td><td class="left">True</td><td class="left">True, iff I have initiated closing handshake (that is, did send close first).</td></tr> <tr class="stats_row"><td>failedByMe</td><td class="left">False</td><td class="left">True, iff I have failed the WS connection (i.e. due to protocol error). Failing can be either by initiating closing handshake or brutal drop TCP.</td></tr> <tr class="stats_row"><td>droppedByMe</td><td class="left">True</td><td class="left">True, iff I dropped the TCP connection.</td></tr> <tr class="stats_row"><td>wasClean</td><td class="left">True</td><td class="left">True, iff full WebSockets closing handshake was performed (close frame sent and received) _and_ the server dropped the TCP (which is its responsibility).</td></tr> <tr class="stats_row"><td>wasNotCleanReason</td><td class="left">None</td><td class="left">When wasClean == False, the reason what happened.</td></tr> <tr class="stats_row"><td>wasServerConnectionDropTimeout</td><td class="left">False</td><td class="left">When we are a client, and we expected the server to drop the TCP, but that didn't happen in time, this gets True.</td></tr> <tr class="stats_row"><td>wasOpenHandshakeTimeout</td><td class="left">False</td><td class="left">When performing the opening handshake, but the peer did not finish in time, this gets True.</td></tr> <tr class="stats_row"><td>wasCloseHandshakeTimeout</td><td class="left">False</td><td class="left">When we initiated a closing handshake, but the peer did not respond in time, this gets True.</td></tr> <tr class="stats_row"><td>localCloseCode</td><td class="left">1003</td><td class="left">The close code I sent in close frame (if any).</td></tr> <tr class="stats_row"><td>localCloseReason</td><td class="left">None</td><td class="left">The close reason I sent in close frame (if any).</td></tr> <tr class="stats_row"><td>remoteCloseCode</td><td class="left">1003</td><td class="left">The close code the peer sent me in close frame (if any).</td></tr> <tr class="stats_row"><td>remoteCloseReason</td><td class="left">None</td><td class="left">The close reason the peer sent me in close frame (if any).</td></tr> </table> <br/><hr/> <h2>Wire Statistics</h2> <h3>Octets Received by Chop Size</h3> <table> <tr class="stats_header"><td>Chop Size</td><td>Count</td><td>Octets</td></tr> <tr class="stats_row"><td>8</td><td>1</td><td>8</td></tr> <tr class="stats_row"><td>181</td><td>1</td><td>181</td></tr> <tr class="stats_total"><td>Total</td><td>2</td><td>189</td></tr> </table> <h3>Octets Transmitted by Chop Size</h3> <table> <tr class="stats_header"><td>Chop Size</td><td>Count</td><td>Octets</td></tr> <tr class="stats_row"><td>4</td><td>1</td><td>4</td></tr> <tr class="stats_row"><td>169</td><td>1</td><td>169</td></tr> <tr class="stats_total"><td>Total</td><td>2</td><td>173</td></tr> </table> <h3>Frames Received by Opcode</h3> <table> <tr class="stats_header"><td>Opcode</td><td>Count</td></tr> <tr class="stats_row"><td>8</td><td>1</td></tr> <tr class="stats_total"><td>Total</td><td>1</td></tr> </table> <h3>Frames Transmitted by Opcode</h3> <table> <tr class="stats_header"><td>Opcode</td><td>Count</td></tr> <tr class="stats_row"><td>8</td><td>1</td></tr> <tr class="stats_total"><td>Total</td><td>1</td></tr> </table> <br/><hr/> <h2>Wire Log</h2> <div id="wirelog"> <pre class="wirelog_rx_octets">000 RX OCTETS: 474554202f72756e436173653f636173653d323232266167656e743d736e61636b6120485454502f312e310d0a486f73743a</pre> <pre class="wirelog_rx_octets"> 206c6f63616c686f73743a393030 ...</pre> <pre class="wirelog_tx_octets">001 TX OCTETS: 485454502f312e312031303120537769746368696e672050726f746f636f6c730d0a5365727665723a204175746f6261686e</pre> <pre class="wirelog_tx_octets"> 5465737453756974652f302e352e ...</pre> <pre class="wirelog_tx_frame">002 TX FRAME : OPCODE=8, FIN=True, RSV=0, PAYLOAD-LEN=2, MASK=None, PAYLOAD-REPEAT-LEN=None, CHOPSIZE=None, SYNC=False</pre> <pre class="wirelog_tx_frame"> 0x03eb</pre> <pre class="wirelog_tx_octets">003 TX OCTETS: 880203eb</pre> <pre class="wirelog_kill_after">004 FAIL CONNECTION AFTER 1.000000 sec</pre> <pre class="wirelog_rx_octets">005 RX OCTETS: 888262fd32e86116</pre> <pre class="wirelog_rx_frame">006 RX FRAME : OPCODE=8, FIN=True, RSV=0, PAYLOAD-LEN=2, MASKED=True, MASK=3632666433326538</pre> <pre class="wirelog_rx_frame"> 0x03eb</pre> <pre class="wirelog_tcp_closed_by_me">007 TCP DROPPED BY ME</pre> </div> <br/><hr/> </body> </html>
stuffmatic/snacka
doc/autobahntestresults/snacka_case_7_7_4.html
HTML
bsd-2-clause
10,654
/* $NiH: add_from_buffer.c,v 1.3 2006/05/09 23:41:32 wiz Exp $ add_from_buffer.c -- test case for adding file from buffer to archive Copyright (C) 1999, 2003, 2005 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <nih@giga.or.at> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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 <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "zip.h" const char *teststr="This is a test, and it seems to have been successful.\n"; const char *file="teststring.txt"; const char *prg; int main(int argc, char *argv[]) { const char *archive; struct zip *za; struct zip_source *zs; char buf[100]; int err; prg = argv[0]; if (argc != 2) { fprintf(stderr, "usage: %s archive\n", prg); return 1; } archive = argv[1]; if ((za=zip_open(archive, ZIP_CREATE, &err)) == NULL) { zip_error_to_str(buf, sizeof(buf), err, errno); fprintf(stderr,"%s: can't open zip archive %s: %s\n", prg, archive, buf); return 1; } if ((zs=zip_source_buffer(za, teststr, strlen(teststr), 0)) == NULL) { fprintf(stderr,"%s: can't create zip_source from buffer: %s\n", prg, zip_strerror(za)); exit(1); } if (zip_add(za, file, zs) == -1) { zip_source_free(zs); fprintf(stderr,"%s: can't add file `%s': %s\n", prg, file, zip_strerror(za)); return 1; } if (zip_close(za) == -1) { fprintf(stderr,"%s: can't close zip archive %s\n", prg, archive); return 1; } return 0; }
vlm/zip-fix-filename-encoding
libzip-0.7.1/regress/add_from_buffer.c
C
bsd-2-clause
2,911
package de.pfabulist.lindwurm.eighty; import de.pfabulist.lindwurm.eighty.path.EightyPath; import de.pfabulist.lindwurm.eighty.watch.WatchableByteChannel; import javax.annotation.Nullable; import java.io.IOException; import java.nio.channels.FileChannel; import java.nio.channels.SeekableByteChannel; import java.nio.file.AccessDeniedException; import java.nio.file.FileAlreadyExistsException; import java.nio.file.FileSystemException; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.OpenOption; import java.nio.file.Path; import java.nio.file.ReadOnlyFileSystemException; import java.nio.file.StandardWatchEventKinds; import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.FileTime; import java.time.Clock; import java.util.HashSet; import java.util.Set; import java.util.function.BiFunction; import static de.pfabulist.kleinod.nio.PathIKWID.childGetParent; import static de.pfabulist.lindwurm.eighty.EightyUtils.throwIfPathIsNotAccessible; import static de.pfabulist.lindwurm.eighty.path.ProviderPath.toRealPath; import static java.nio.file.StandardOpenOption.APPEND; import static java.nio.file.StandardOpenOption.CREATE; import static java.nio.file.StandardOpenOption.CREATE_NEW; import static java.nio.file.StandardOpenOption.READ; import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; import static java.nio.file.StandardOpenOption.WRITE; /** * ** BEGIN LICENSE BLOCK ***** * BSD License (2 clause) * Copyright (c) 2006 - 2015, Stephan Pfab * All rights reserved. * <p> * 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. * <p> * 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 Stephan Pfab 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. * **** END LICENSE BLOCK **** */ @SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.ModifiedCyclomaticComplexity", "PMD.StdCyclomaticComplexity" }) public class ProviderChannel { @SuppressWarnings({ "PMD.NPathComplexity" }) public static <T extends SeekableByteChannel> FileChannel newChannel( EightyPath pathArg, Set<? extends OpenOption> options, BiFunction<EightyPath, Set<OpenOption>, T> create ) throws IOException { final EightyFileSystem eightyFileSystem = pathArg._getFileSystem(); EightyPath path = toRealPath( pathArg ); Set<OpenOption> impliedOptions = new HashSet<>( options ); if( impliedOptions.isEmpty() ) { impliedOptions.add( READ ); } if ( impliedOptions.contains( APPEND )) { impliedOptions.add( WRITE ); } newByteChannelParentCheck( path ); throwIfPathIsNotAccessible( path ); boolean creating = byteChannelCheckExistence( options, path ); if( options.contains( APPEND ) && options.contains( READ ) ) { throw new IllegalArgumentException( "APPEND + READ not allowed" ); } if( options.contains( APPEND ) && options.contains( TRUNCATE_EXISTING ) ) { throw new IllegalArgumentException( "APPEND + TRUNCATE_EXISTING not allowed" ); } if( Files.isDirectory( path ) ) { throw new FileSystemException( path.toString() + " is a directory" ); } if( impliedOptions.contains( WRITE ) ) { if( eightyFileSystem.isReadOnly() ) { throw new ReadOnlyFileSystemException(); } if ( !creating && !Files.isWritable( path )) { throw new AccessDeniedException( "file not writable" ); } } if ( creating ) { eightyFileSystem.get80().newContent( path ); } T unwachedChannel = eightyFileSystem.addClosable( create.apply( path, impliedOptions ) ); FileChannel ret = new WatchableByteChannel( unwachedChannel, () -> eightyFileSystem.signal( path, StandardWatchEventKinds.ENTRY_MODIFY )); if( creating ) { // e.g. means has a a parent FileTime now = FileTime.from( Clock.systemUTC().instant() ); Files.getFileAttributeView( childGetParent( path ), BasicFileAttributeView.class ).setTimes( now, now, null ); path._getFileSystem().signal( path, StandardWatchEventKinds.ENTRY_CREATE ); } else if ( impliedOptions.contains( WRITE )) { path._getFileSystem().signal( path, StandardWatchEventKinds.ENTRY_MODIFY ); } return ret; } private static boolean byteChannelCheckExistence( Set<? extends OpenOption> options, EightyPath path ) throws NoSuchFileException, FileAlreadyExistsException { boolean creating = false; if( !Files.exists( path ) ) { creating = true; if( !options.contains( WRITE ) ) { throw new NoSuchFileException( path.toString() ); } if( !options.contains( CREATE ) && !options.contains( CREATE_NEW ) ) { throw new NoSuchFileException( path.toString() ); } } else { if( options.contains( CREATE_NEW ) ) { throw new FileAlreadyExistsException( path.toString() ); } } return creating; } private static void newByteChannelParentCheck( EightyPath path ) throws FileSystemException { @Nullable Path parent = path.getParent(); if( parent == null ) { return; // todo handle } if( !Files.exists( parent ) ) { throw new NoSuchFileException( parent.toString() ); } if( !Files.isDirectory( parent ) ) { throw new FileSystemException( "parent is not a directory" ); } } }
openCage/eightyfs
src/main/java/de/pfabulist/lindwurm/eighty/ProviderChannel.java
Java
bsd-2-clause
6,742
body { margin: 0px; background-color: #000; color: #fff; font-family: 'Roboto Condensed', sans-serif; } #webspec { width: 100%; height: 100%; margin: 0px; } #errorTitle { font-size: x-large; } .errorbox { text-align: center; width: 300px; height: 100px; position: absolute; left: 50%; top: 50%; margin: -100px 0 0 -150px; opacity: 0; -webkit-transition: opacity 1s ease; -moz-transition: opacity 1s ease; -o-transition: opacity 1s ease; -ms-transition: opacity 1s ease; transition: opacity 1s ease; background-color: #777; border-radius: 15px; -moz-border-radius: 15px; padding: 10px; } .boxShow { opacity: 1; }
MattMcNam/webspec
client/img/style.css
CSS
bsd-2-clause
683
package br.odb.minefield.commands; import br.odb.gameapp.ConsoleApplication; import br.odb.gameapp.UserCommandLineAction; public class ClearCommand extends UserCommandLineAction { @Override public String getHelp() { return null; } @Override public int requiredOperands() { return 2; } @Override public void run(ConsoleApplication app, String operands) throws Exception { } @Override public String toString() { return "clear"; } }
TheFakeMontyOnTheRun/deep-space-minefield
minefield-core-java/src/main/java/br/odb/minefield/commands/ClearCommand.java
Java
bsd-2-clause
457
package org.mapfish.print.attribute.map; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; public class ZoomLevelsTest { @Test public void testRemoveDuplicates() throws Exception { final ZoomLevels zoomLevels = new ZoomLevels(4, 2, 3, 3, 2, 1, 3, 2, 1); assertEquals(4, zoomLevels.size()); assertEquals(4, (int) zoomLevels.get(0)); assertEquals(3, (int) zoomLevels.get(1)); assertEquals(2, (int) zoomLevels.get(2)); assertEquals(1, (int) zoomLevels.get(3)); } @Test public void testSort() throws Exception { final ZoomLevels zoomLevels = new ZoomLevels(4,2,3,1); assertEquals(4, zoomLevels.size()); assertEquals(4, (int) zoomLevels.get(0)); assertEquals(3, (int) zoomLevels.get(1)); assertEquals(2, (int) zoomLevels.get(2)); assertEquals(1, (int) zoomLevels.get(3)); } @Test public void testEquals() throws Exception { final ZoomLevels zoomLevels1 = new ZoomLevels(4,2,3,0); final ZoomLevels zoomLevels2 = new ZoomLevels(4,2,3,1); final ZoomLevels zoomLevels3 = new ZoomLevels(1, 2, 3, 3, 3, 4); assertEquals(zoomLevels2, zoomLevels3); assertEquals(zoomLevels3, zoomLevels2); assertEquals(zoomLevels2, zoomLevels2); assertEquals(zoomLevels3, zoomLevels3); assertEquals(zoomLevels1, zoomLevels1); assertFalse(zoomLevels1.equals(zoomLevels2)); assertFalse(zoomLevels1.equals(zoomLevels3)); assertFalse(zoomLevels2.equals(zoomLevels1)); } }
Galigeo/mapfish-print
core/src/test/java/org/mapfish/print/attribute/map/ZoomLevelsTest.java
Java
bsd-2-clause
1,633
/* * Copyright (c) 2018, Eadgars Ruse <https://github.com/Eadgars-Ruse> * Copyright (c) 2018, Adam <Adam@sigterm.info> * Copyright (c) 2019, Jordan Atwood <nightfirecat@protonmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. 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. * * 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 OWNER 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. */ package net.runelite.client.plugins.cluescrolls.clues.hotcold; import com.google.common.base.Preconditions; import java.awt.Rectangle; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.coords.WorldPoint; import net.runelite.client.plugins.cluescrolls.clues.Enemy; import static net.runelite.client.plugins.cluescrolls.clues.Enemy.ANCIENT_WIZARDS; import static net.runelite.client.plugins.cluescrolls.clues.Enemy.BRASSICAN_MAGE; import static net.runelite.client.plugins.cluescrolls.clues.Enemy.BRASSICAN_OR_WIZARDS; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.ASGARNIA; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.DESERT; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.FELDIP_HILLS; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.FREMENNIK_PROVINCE; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.KANDARIN; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.KARAMJA; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.MISTHALIN; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.MORYTANIA; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.WESTERN_PROVINCE; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.WILDERNESS; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdArea.ZEAH; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdLocation.HotColdType.BEGINNER; import static net.runelite.client.plugins.cluescrolls.clues.hotcold.HotColdLocation.HotColdType.MASTER; // The locations contains all hot/cold points and their descriptions according to the wiki // these central points were obtained by checking wiki location pictures against a coordinate map // some central points points may be slightly off-center // calculations are done considering the 9x9 grid around the central point where the strange device shakes // because the calculations consider the 9x9 grid, slightly off-center points should still be found by the calculations @AllArgsConstructor @Getter public enum HotColdLocation { ASGARNIA_WARRIORS(MASTER, new WorldPoint(2860, 3562, 0), ASGARNIA, "North of the Warriors' Guild in Burthorpe.", BRASSICAN_MAGE), ASGARNIA_JATIX(MASTER, new WorldPoint(2915, 3425, 0), ASGARNIA, "East of Jatix's Herblore Shop in Taverley.", BRASSICAN_MAGE), ASGARNIA_BARB(MASTER, new WorldPoint(3033, 3438, 0), ASGARNIA, "West of Barbarian Village.", BRASSICAN_MAGE), ASGARNIA_MIAZRQA(MASTER, new WorldPoint(2972, 3486, 0), ASGARNIA, "North of Miazrqa's tower, outside Goblin Village.", BRASSICAN_MAGE), ASGARNIA_COW(MASTER, new WorldPoint(3031, 3304, 0), ASGARNIA, "In the cow pen north of Sarah's Farming Shop.", ANCIENT_WIZARDS), ASGARNIA_PARTY_ROOM(MASTER, new WorldPoint(3030, 3364, 0), ASGARNIA, "Outside the Falador Party Room.", BRASSICAN_MAGE), ASGARNIA_CRAFT_GUILD(MASTER, new WorldPoint(2917, 3295, 0), ASGARNIA, "Outside the Crafting Guild cow pen.", BRASSICAN_MAGE), ASGARNIA_RIMMINGTON(MASTER, new WorldPoint(2976, 3239, 0), ASGARNIA, "In the centre of the Rimmington mine.", BRASSICAN_MAGE), ASGARNIA_MUDSKIPPER(MASTER, new WorldPoint(2987, 3110, 0), ASGARNIA, "Mudskipper Point, near the starfish in the south-west corner.", BRASSICAN_MAGE), ASGARNIA_TROLL(MASTER, new WorldPoint(2910, 3615, 0), ASGARNIA, "The Troll arena, where the player fights Dad during the Troll Stronghold quest. Bring climbing boots if travelling from Burthorpe.", BRASSICAN_MAGE), DESERT_GENIE(MASTER, new WorldPoint(3359, 2912, 0), DESERT, "West of Nardah genie cave.", BRASSICAN_MAGE), DESERT_ALKHARID_MINE(MASTER, new WorldPoint(3279, 3263, 0), DESERT, "West of Al Kharid mine.", BRASSICAN_MAGE), DESERT_MENAPHOS_GATE(MASTER, new WorldPoint(3223, 2820, 0), DESERT, "North of Menaphos gate.", BRASSICAN_MAGE), DESERT_BEDABIN_CAMP(MASTER, new WorldPoint(3161, 3047, 0), DESERT, "Bedabin Camp, near the north tent.", BRASSICAN_MAGE), DESERT_UZER(MASTER, new WorldPoint(3432, 3105, 0), DESERT, "West of Uzer.", BRASSICAN_MAGE), DESERT_POLLNIVNEACH(MASTER, new WorldPoint(3288, 2976, 0), DESERT, "West of Pollnivneach.", BRASSICAN_MAGE), DESERT_MTA(MASTER, new WorldPoint(3347, 3295, 0), DESERT, "Next to Mage Training Arena.", BRASSICAN_MAGE), DESERT_SHANTY(MASTER, new WorldPoint(3292, 3107, 0), DESERT, "South-west of Shantay Pass.", BRASSICAN_MAGE), DRAYNOR_MANOR_MUSHROOMS(BEGINNER, new WorldPoint(3096, 3379, 0), MISTHALIN, "Patch of mushrooms just northwest of Draynor Manor"), DRAYNOR_WHEAT_FIELD(BEGINNER, new WorldPoint(3120, 3282, 0), MISTHALIN, "Inside the wheat field next to Draynor Village"), FELDIP_HILLS_JIGGIG(MASTER, new WorldPoint(2409, 3053, 0), FELDIP_HILLS, "West of Jiggig, east of the fairy ring BKP.", BRASSICAN_MAGE), FELDIP_HILLS_SW(MASTER, new WorldPoint(2586, 2897, 0), FELDIP_HILLS, "West of the southeasternmost lake in Feldip Hills.", BRASSICAN_MAGE), FELDIP_HILLS_GNOME_GLITER(MASTER, new WorldPoint(2555, 2972, 0), FELDIP_HILLS, "East of the gnome glider (Lemantolly Undri).", BRASSICAN_MAGE), FELDIP_HILLS_RANTZ(MASTER, new WorldPoint(2611, 2950, 0), FELDIP_HILLS, "South of Rantz, west of the empty glass bottles.", BRASSICAN_MAGE), FELDIP_HILLS_SOUTH(MASTER, new WorldPoint(2486, 3007, 0), FELDIP_HILLS, "South of Jiggig.", BRASSICAN_MAGE), FELDIP_HILLS_RED_CHIN(MASTER, new WorldPoint(2530, 2901, 0), FELDIP_HILLS, "Outside the red chinchompa hunting ground entrance, south of the Hunting expert's hut.", BRASSICAN_MAGE), FELDIP_HILLS_SE(MASTER, new WorldPoint(2569, 2918, 0), FELDIP_HILLS, "South-east of the ∩-shaped lake, near the Hunter icon.", BRASSICAN_MAGE), FELDIP_HILLS_CW_BALLOON(MASTER, new WorldPoint(2451, 3112, 0), FELDIP_HILLS, "Directly west of the Castle Wars balloon.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_MTN_CAMP(MASTER, new WorldPoint(2800, 3669, 0), FREMENNIK_PROVINCE, "At the Mountain Camp.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_RELLEKKA_HUNTER(MASTER, new WorldPoint(2720, 3784, 0), FREMENNIK_PROVINCE, "At the Rellekka Hunter area, near the Hunter icon.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_KELGADRIM_ENTRANCE(MASTER, new WorldPoint(2711, 3689, 0), FREMENNIK_PROVINCE, "West of the Keldagrim entrance mine.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_SW(MASTER, new WorldPoint(2604, 3648, 0), FREMENNIK_PROVINCE, "Outside the fence in the south-western corner of Rellekka.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_LIGHTHOUSE(MASTER, new WorldPoint(2585, 3601, 0), FREMENNIK_PROVINCE, "South-east of the Lighthouse.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_ETCETERIA_CASTLE(MASTER, new WorldPoint(2617, 3862, 0), FREMENNIK_PROVINCE, "South-east of Etceteria's castle.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_MISC_COURTYARD(MASTER, new WorldPoint(2527, 3868, 0), FREMENNIK_PROVINCE, "Outside Miscellania's courtyard.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_FREMMY_ISLES_MINE(MASTER, new WorldPoint(2374, 3850, 0), FREMENNIK_PROVINCE, "Central Fremennik Isles mine.", ANCIENT_WIZARDS), FREMENNIK_PROVINCE_WEST_ISLES_MINE(MASTER, new WorldPoint(2313, 3850, 0), FREMENNIK_PROVINCE, "West Fremennik Isles mine.", ANCIENT_WIZARDS), FREMENNIK_PROVINCE_WEST_JATIZSO_ENTRANCE(MASTER, new WorldPoint(2393, 3812, 0), FREMENNIK_PROVINCE, "West of the Jatizso mine entrance.", BRASSICAN_MAGE), FREMENNIK_PROVINCE_PIRATES_COVE(MASTER, new WorldPoint(2211, 3817, 0), FREMENNIK_PROVINCE, "Pirates' Cove", ANCIENT_WIZARDS), FREMENNIK_PROVINCE_ASTRAL_ALTER(MASTER, new WorldPoint(2149, 3865, 0), FREMENNIK_PROVINCE, "Astral altar", ANCIENT_WIZARDS), FREMENNIK_PROVINCE_LUNAR_VILLAGE(MASTER, new WorldPoint(2084, 3916, 0), FREMENNIK_PROVINCE, "Lunar Isle, inside the village.", ANCIENT_WIZARDS), FREMENNIK_PROVINCE_LUNAR_NORTH(MASTER, new WorldPoint(2106, 3949, 0), FREMENNIK_PROVINCE, "Lunar Isle, north of the village.", ANCIENT_WIZARDS), ICE_MOUNTAIN(BEGINNER, new WorldPoint(3007, 3475, 0), MISTHALIN, "Atop Ice Mountain"), ISLE_OF_SOULS_MINE(MASTER, new WorldPoint(2189, 2794, 0), KANDARIN, "Isle of Souls Mine, south of the Soul Wars lobby", BRASSICAN_MAGE), KANDARIN_SINCLAR_MANSION(MASTER, new WorldPoint(2730, 3588, 0), KANDARIN, "North-west of the Sinclair Mansion, near the log balance shortcut.", BRASSICAN_MAGE), KANDARIN_CATHERBY(MASTER, new WorldPoint(2774, 3436, 0), KANDARIN, "Catherby, between the bank and the beehives, near small rock formation.", BRASSICAN_MAGE), KANDARIN_GRAND_TREE(MASTER, new WorldPoint(2448, 3503, 0), KANDARIN, "Grand Tree, just east of the terrorchick gnome enclosure.", BRASSICAN_MAGE), KANDARIN_SEERS(MASTER, new WorldPoint(2732, 3485, 0), KANDARIN, "Outside Seers' Village bank.", BRASSICAN_MAGE), KANDARIN_MCGRUBORS_WOOD(MASTER, new WorldPoint(2653, 3485, 0), KANDARIN, "McGrubor's Wood", BRASSICAN_MAGE), KANDARIN_FISHING_BUILD(MASTER, new WorldPoint(2590, 3369, 0), KANDARIN, "South of Fishing Guild", BRASSICAN_MAGE), KANDARIN_WITCHHAVEN(MASTER, new WorldPoint(2707, 3306, 0), KANDARIN, "Outside Witchaven, west of Jeb, Holgart, and Caroline.", BRASSICAN_MAGE), KANDARIN_NECRO_TOWER(MASTER, new WorldPoint(2667, 3241, 0), KANDARIN, "Ground floor inside the Necromancer Tower. Easily accessed by using fairy ring code djp.", ANCIENT_WIZARDS), KANDARIN_FIGHT_ARENA(MASTER, new WorldPoint(2587, 3135, 0), KANDARIN, "South of the Fight Arena, north-west of the Nightmare Zone.", BRASSICAN_MAGE), KANDARIN_TREE_GNOME_VILLAGE(MASTER, new WorldPoint(2530, 3164, 0), KANDARIN, "Tree Gnome Village, near the general store icon.", BRASSICAN_MAGE), KANDARIN_GRAVE_OF_SCORPIUS(MASTER, new WorldPoint(2467, 3227, 0), KANDARIN, "Grave of Scorpius", BRASSICAN_MAGE), KANDARIN_KHAZARD_BATTLEFIELD(MASTER, new WorldPoint(2522, 3252, 0), KANDARIN, "Khazard Battlefield, south of Tracker gnome 2.", BRASSICAN_MAGE), KANDARIN_WEST_ARDY(MASTER, new WorldPoint(2535, 3322, 0), KANDARIN, "West Ardougne, near the staircase outside the Civic Office.", BRASSICAN_MAGE), KANDARIN_SW_TREE_GNOME_STRONGHOLD(MASTER, new WorldPoint(2411, 3429, 0), KANDARIN, "South-west Tree Gnome Stronghold", BRASSICAN_MAGE), KANDARIN_OUTPOST(MASTER, new WorldPoint(2457, 3362, 0), KANDARIN, "South of the Tree Gnome Stronghold, north-east of the Outpost.", BRASSICAN_MAGE), KANDARIN_BAXTORIAN_FALLS(MASTER, new WorldPoint(2530, 3477, 0), KANDARIN, "South-east of Almera's house on Baxtorian Falls.", BRASSICAN_MAGE), KANDARIN_BA_AGILITY_COURSE(MASTER, new WorldPoint(2540, 3548, 0), KANDARIN, "Inside the Barbarian Agility Course. Completion of Alfred Grimhand's Barcrawl is required.", BRASSICAN_MAGE), KARAMJA_MUSA_POINT(MASTER, new WorldPoint(2913, 3169, 0), KARAMJA, "Musa Point, banana plantation.", BRASSICAN_MAGE), KARAMJA_BRIMHAVEN_FRUIT_TREE(MASTER, new WorldPoint(2782, 3215, 0), KARAMJA, "Brimhaven, east of the fruit tree patch.", BRASSICAN_MAGE), KARAMJA_WEST_BRIMHAVEN(MASTER, new WorldPoint(2718, 3167, 0), KARAMJA, "West of Brimhaven.", BRASSICAN_MAGE), KARAMJA_GLIDER(MASTER, new WorldPoint(2966, 2976, 0), KARAMJA, "West of the gnome glider.", BRASSICAN_MAGE), KARAMJA_KHARAZI_NE(MASTER, new WorldPoint(2904, 2925, 0), KARAMJA, "North-eastern part of Kharazi Jungle.", BRASSICAN_MAGE), KARAMJA_KHARAZI_SW(MASTER, new WorldPoint(2786, 2899, 0), KARAMJA, "South-western part of Kharazi Jungle.", BRASSICAN_MAGE), KARAMJA_CRASH_ISLAND(MASTER, new WorldPoint(2909, 2737, 0), KARAMJA, "Northern part of Crash Island.", BRASSICAN_MAGE), LUMBRIDGE_COW_FIELD(BEGINNER, new WorldPoint(3174, 3336, 0), MISTHALIN, "Cow field north of Lumbridge"), MISTHALIN_VARROCK_STONE_CIRCLE(MASTER, new WorldPoint(3225, 3356, 0), MISTHALIN, "South of the stone circle near Varrock's entrance.", BRASSICAN_MAGE), MISTHALIN_LUMBRIDGE(MASTER, new WorldPoint(3234, 3169, 0), MISTHALIN, "Just north-west of the Lumbridge Fishing tutor.", BRASSICAN_MAGE), MISTHALIN_LUMBRIDGE_2(MASTER, new WorldPoint(3169, 3279, 0), MISTHALIN, "North of the pond between Lumbridge and Draynor Village.", BRASSICAN_MAGE), MISTHALIN_GERTUDES(MASTER, new WorldPoint(3154, 3421, 0), MISTHALIN, "North-east of Gertrude's house west of Varrock.", BRASSICAN_MAGE), MISTHALIN_DRAYNOR_BANK(MASTER, new WorldPoint(3098, 3234, 0), MISTHALIN, "South of Draynor Village bank.", BRASSICAN_MAGE), MISTHALIN_LUMBER_YARD(MASTER, new WorldPoint(3301, 3484, 0), MISTHALIN, "South of Lumber Yard, east of Assistant Serf.", BRASSICAN_MAGE), MORYTANIA_BURGH_DE_ROTT(MASTER, new WorldPoint(3546, 3252, 0), MORYTANIA, "In the north-east area of Burgh de Rott, by the reverse-L-shaped ruins.", BRASSICAN_MAGE), MORYTANIA_DARKMEYER(MASTER, new WorldPoint(3604, 3326, 0), MORYTANIA, "Southwestern part of Darkmeyer.", BRASSICAN_MAGE), MORYTANIA_PORT_PHASMATYS(MASTER, new WorldPoint(3611, 3485, 0), MORYTANIA, "West of Port Phasmatys, south-east of fairy ring.", BRASSICAN_MAGE), MORYTANIA_HOLLOWS(MASTER, new WorldPoint(3499, 3421, 0), MORYTANIA, "Inside The Hollows, south of the bridge which was repaired in a quest.", BRASSICAN_MAGE), MORYTANIA_SWAMP(MASTER, new WorldPoint(3418, 3372, 0), MORYTANIA, "Inside the Mort Myre Swamp, north-west of the Nature Grotto.", BRASSICAN_MAGE), MORYTANIA_HAUNTED_MINE(MASTER, new WorldPoint(3444, 3255, 0), MORYTANIA, "At Haunted Mine quest start.", BRASSICAN_MAGE), MORYTANIA_MAUSOLEUM(MASTER, new WorldPoint(3499, 3539, 0), MORYTANIA, "South of the Mausoleum.", BRASSICAN_MAGE), MORYTANIA_MOS_LES_HARMLESS(MASTER, new WorldPoint(3740, 3041, 0), MORYTANIA, "Northern area of Mos Le'Harmless, between the lakes.", BRASSICAN_MAGE), MORYTANIA_MOS_LES_HARMLESS_BAR(MASTER, new WorldPoint(3666, 2972, 0), MORYTANIA, "Near Mos Le'Harmless southern bar.", BRASSICAN_MAGE), MORYTANIA_DRAGONTOOTH_NORTH(MASTER, new WorldPoint(3811, 3569, 0), MORYTANIA, "Northern part of Dragontooth Island.", BRASSICAN_MAGE), MORYTANIA_DRAGONTOOTH_SOUTH(MASTER, new WorldPoint(3803, 3532, 0), MORYTANIA, "Southern part of Dragontooth Island.", BRASSICAN_MAGE), MORYTANIA_SLEPE_TENTS(MASTER, new WorldPoint(3769, 3383, 0), MORYTANIA, "North-east of Slepe, near the tents.", BRASSICAN_MAGE), NORTHEAST_OF_AL_KHARID_MINE(BEGINNER, new WorldPoint(3332, 3313, 0), MISTHALIN, "Northeast of Al Kharid Mine"), WESTERN_PROVINCE_EAGLES_PEAK(MASTER, new WorldPoint(2297, 3529, 0), WESTERN_PROVINCE, "North-west of Eagles' Peak.", BRASSICAN_MAGE), WESTERN_PROVINCE_PISCATORIS(MASTER, new WorldPoint(2334, 3685, 0), WESTERN_PROVINCE, "Piscatoris Fishing Colony", ANCIENT_WIZARDS), WESTERN_PROVINCE_PISCATORIS_HUNTER_AREA(MASTER, new WorldPoint(2359, 3564, 0), WESTERN_PROVINCE, "Eastern part of Piscatoris Hunter area, south-west of the Falconry.", BRASSICAN_MAGE), WESTERN_PROVINCE_ARANDAR(MASTER, new WorldPoint(2370, 3319, 0), WESTERN_PROVINCE, "South-west of the crystal gate to Arandar.", ANCIENT_WIZARDS), WESTERN_PROVINCE_ELF_CAMP_EAST(MASTER, new WorldPoint(2268, 3242, 0), WESTERN_PROVINCE, "East of Iorwerth Camp.", BRASSICAN_MAGE), WESTERN_PROVINCE_ELF_CAMP_NW(MASTER, new WorldPoint(2177, 3282, 0), WESTERN_PROVINCE, "North-west of Iorwerth Camp.", BRASSICAN_MAGE), WESTERN_PROVINCE_LLETYA(MASTER, new WorldPoint(2337, 3166, 0), WESTERN_PROVINCE, "In Lletya.", BRASSICAN_MAGE), WESTERN_PROVINCE_TYRAS(MASTER, new WorldPoint(2206, 3158, 0), WESTERN_PROVINCE, "Near Tyras Camp.", BRASSICAN_MAGE), WESTERN_PROVINCE_ZULANDRA(MASTER, new WorldPoint(2196, 3057, 0), WESTERN_PROVINCE, "The northern house at Zul-Andra.", BRASSICAN_MAGE), WILDERNESS_5(MASTER, new WorldPoint(3173, 3556, 0), WILDERNESS, "North of the Grand Exchange, level 5 Wilderness.", ANCIENT_WIZARDS), WILDERNESS_12(MASTER, new WorldPoint(3036, 3612, 0), WILDERNESS, "South-east of the Dark Warriors' Fortress, level 12 Wilderness.", ANCIENT_WIZARDS), WILDERNESS_20(MASTER, new WorldPoint(3222, 3679, 0), WILDERNESS, "East of the Corporeal Beast's lair, level 20 Wilderness.", ANCIENT_WIZARDS), WILDERNESS_27(MASTER, new WorldPoint(3174, 3736, 0), WILDERNESS, "Inside the Ruins north of the Graveyard of Shadows, level 27 Wilderness.", BRASSICAN_MAGE), WILDERNESS_28(MASTER, new WorldPoint(3377, 3737, 0), WILDERNESS, "East of Venenatis' nest, level 28 Wilderness.", BRASSICAN_MAGE), WILDERNESS_32(MASTER, new WorldPoint(3311, 3773, 0), WILDERNESS, "North of Venenatis' nest, level 32 Wilderness.", ANCIENT_WIZARDS), WILDERNESS_35(MASTER, new WorldPoint(3152, 3796, 0), WILDERNESS, "East of the Wilderness canoe exit, level 35 Wilderness.", BRASSICAN_OR_WIZARDS), WILDERNESS_37(MASTER, new WorldPoint(2974, 3814, 0), WILDERNESS, "South-east of the Chaos Temple, level 37 Wilderness.", BRASSICAN_MAGE), WILDERNESS_38(MASTER, new WorldPoint(3293, 3813, 0), WILDERNESS, "South of Callisto, level 38 Wilderness.", ANCIENT_WIZARDS), WILDERNESS_49(MASTER, new WorldPoint(3136, 3914, 0), WILDERNESS, "South-west of the Deserted Keep, level 49 Wilderness.", BRASSICAN_MAGE), WILDERNESS_54(MASTER, new WorldPoint(2981, 3944, 0), WILDERNESS, "West of the Wilderness Agility Course, level 54 Wilderness.", BRASSICAN_MAGE), ZEAH_BLASTMINE_BANK(MASTER, new WorldPoint(1504, 3859, 0), ZEAH, "Next to the bank in the Lovakengj blast mine.", BRASSICAN_MAGE), ZEAH_BLASTMINE_NORTH(MASTER, new WorldPoint(1488, 3881, 0), ZEAH, "Northern part of the Lovakengj blast mine.", BRASSICAN_MAGE), ZEAH_LOVAKITE_FURNACE(MASTER, new WorldPoint(1507, 3819, 0), ZEAH, "Next to the lovakite furnace in Lovakengj.", BRASSICAN_MAGE), ZEAH_LOVAKENGJ_MINE(MASTER, new WorldPoint(1477, 3778, 0), ZEAH, "Next to mithril rock in the Lovakengj mine.", BRASSICAN_MAGE), ZEAH_SULPHR_MINE(MASTER, new WorldPoint(1428, 3869, 0), ZEAH, "Western entrance in the Lovakengj sulphur mine. Facemask or Slayer Helmet recommended.", BRASSICAN_MAGE), ZEAH_SHAYZIEN_BANK(MASTER, new WorldPoint(1498, 3627, 0), ZEAH, "South-east of the bank in Shayzien Encampment.", BRASSICAN_MAGE), ZEAH_OVERPASS(MASTER, new WorldPoint(1467, 3714, 0), ZEAH, "Overpass between Lovakengj and Shayzien.", BRASSICAN_MAGE), ZEAH_LIZARDMAN(MASTER, new WorldPoint(1490, 3698, 0), ZEAH, "Within Lizardman Canyon, east of the ladder. Requires 5% favour with Shayzien.", ANCIENT_WIZARDS), ZEAH_COMBAT_RING(MASTER, new WorldPoint(1557, 3624, 0), ZEAH, "Shayzien Encampment, south-east of the Combat Ring.", BRASSICAN_MAGE), ZEAH_SHAYZIEN_BANK_2(MASTER, new WorldPoint(1490, 3602, 0), ZEAH, "North of the bank in Shayzien.", BRASSICAN_MAGE), ZEAH_LIBRARY(MASTER, new WorldPoint(1603, 3843, 0), ZEAH, "North-west of the Arceuus Library.", BRASSICAN_MAGE), ZEAH_HOUSECHURCH(MASTER, new WorldPoint(1682, 3792, 0), ZEAH, "By the entrance to the Arceuus church.", ANCIENT_WIZARDS), ZEAH_DARK_ALTAR(MASTER, new WorldPoint(1698, 3881, 0), ZEAH, "West of the Dark Altar.", BRASSICAN_MAGE), ZEAH_ARCEUUS_HOUSE(MASTER, new WorldPoint(1710, 3700, 0), ZEAH, "By the south-eastern entrance to Arceuus.", BRASSICAN_MAGE), ZEAH_ESSENCE_MINE(MASTER, new WorldPoint(1762, 3852, 0), ZEAH, "By the Arceuus essence mine.", BRASSICAN_MAGE), ZEAH_ESSENCE_MINE_NE(MASTER, new WorldPoint(1773, 3867, 0), ZEAH, "North-east of the Arceuus essence mine.", BRASSICAN_MAGE), ZEAH_PISCARILUS_MINE(MASTER, new WorldPoint(1768, 3705, 0), ZEAH, "South of the Piscarilius mine.", ANCIENT_WIZARDS), ZEAH_GOLDEN_FIELD_TAVERN(MASTER, new WorldPoint(1718, 3643, 0), ZEAH, "South of the gravestone in Kingstown.", BRASSICAN_MAGE), ZEAH_MESS_HALL(MASTER, new WorldPoint(1656, 3621, 0), ZEAH, "East of the Mess hall.", BRASSICAN_MAGE), ZEAH_WATSONS_HOUSE(MASTER, new WorldPoint(1653, 3573, 0), ZEAH, "East of Watson's house.", BRASSICAN_MAGE), ZEAH_VANNAHS_FARM_STORE(MASTER, new WorldPoint(1807, 3523, 0), ZEAH, "North of Tithe Farm, next to the pond.", BRASSICAN_MAGE), ZEAH_FARMING_GUILD_W(MASTER, new WorldPoint(1208, 3736, 0), ZEAH, "West of the Farming Guild.", BRASSICAN_MAGE), ZEAH_DAIRY_COW(MASTER, new WorldPoint(1324, 3722, 0), ZEAH, "North-east of the Kebos Lowlands, east of the dairy cow.", BRASSICAN_MAGE), ZEAH_CRIMSON_SWIFTS(MASTER, new WorldPoint(1187, 3580, 0), ZEAH, "South-west of the Kebos Swamp, below the crimson swifts.", BRASSICAN_MAGE); private final HotColdType type; private final WorldPoint worldPoint; private final HotColdArea hotColdArea; private final String area; private final Enemy enemy; public enum HotColdType { BEGINNER, MASTER, ; } HotColdLocation(HotColdType type, WorldPoint worldPoint, HotColdArea hotColdArea, String areaDescription) { this(type, worldPoint, hotColdArea, areaDescription, null); // only master clues have enemies, so if no enemy it must be a beginner clue Preconditions.checkArgument(type == BEGINNER, "locations without bosses must be beginner"); } public Rectangle getRect() { final int digRadius = isBeginnerClue() ? HotColdTemperature.BEGINNER_VISIBLY_SHAKING.getMaxDistance() : HotColdTemperature.MASTER_VISIBLY_SHAKING.getMaxDistance(); return new Rectangle(worldPoint.getX() - digRadius, worldPoint.getY() - digRadius, digRadius * 2 + 1, digRadius * 2 + 1); } public boolean isBeginnerClue() { return type == BEGINNER; } }
runelite/runelite
runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/hotcold/HotColdLocation.java
Java
bsd-2-clause
22,616
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>basic_socket::lowest_layer_type</title> <link rel="stylesheet" href="../../../boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> <link rel="home" href="../../../index.html" title="Asio"> <link rel="up" href="../basic_socket.html" title="basic_socket"> <link rel="prev" href="lowest_layer/overload2.html" title="basic_socket::lowest_layer (2 of 2 overloads)"> <link rel="next" href="max_connections.html" title="basic_socket::max_connections"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../../asio.png"></td></tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="lowest_layer/overload2.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../basic_socket.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="max_connections.html"><img src="../../../next.png" alt="Next"></a> </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> <a name="asio.reference.basic_socket.lowest_layer_type"></a><a class="link" href="lowest_layer_type.html" title="basic_socket::lowest_layer_type">basic_socket::lowest_layer_type</a> </h4></div></div></div> <p> <a class="indexterm" name="idp111483088"></a> A <a class="link" href="../basic_socket.html" title="basic_socket"><code class="computeroutput"><span class="identifier">basic_socket</span></code></a> is always the lowest layer. </p> <pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">basic_socket</span><span class="special">&lt;</span> <span class="identifier">Protocol</span><span class="special">,</span> <span class="identifier">SocketService</span> <span class="special">&gt;</span> <span class="identifier">lowest_layer_type</span><span class="special">;</span> </pre> <h6> <a name="asio.reference.basic_socket.lowest_layer_type.h0"></a> <span><a name="asio.reference.basic_socket.lowest_layer_type.types"></a></span><a class="link" href="lowest_layer_type.html#asio.reference.basic_socket.lowest_layer_type.types">Types</a> </h6> <div class="informaltable"><table class="table"> <colgroup> <col> <col> </colgroup> <thead><tr> <th> <p> Name </p> </th> <th> <p> Description </p> </th> </tr></thead> <tbody> <tr> <td> <p> <a class="link" href="broadcast.html" title="basic_socket::broadcast"><span class="bold"><strong>broadcast</strong></span></a> </p> </td> <td> <p> Socket option to permit sending of broadcast messages. </p> </td> </tr> <tr> <td> <p> <a class="link" href="bytes_readable.html" title="basic_socket::bytes_readable"><span class="bold"><strong>bytes_readable</strong></span></a> </p> </td> <td> <p> IO control command to get the amount of data that can be read without blocking. </p> </td> </tr> <tr> <td> <p> <a class="link" href="debug.html" title="basic_socket::debug"><span class="bold"><strong>debug</strong></span></a> </p> </td> <td> <p> Socket option to enable socket-level debugging. </p> </td> </tr> <tr> <td> <p> <a class="link" href="do_not_route.html" title="basic_socket::do_not_route"><span class="bold"><strong>do_not_route</strong></span></a> </p> </td> <td> <p> Socket option to prevent routing, use local interfaces only. </p> </td> </tr> <tr> <td> <p> <a class="link" href="enable_connection_aborted.html" title="basic_socket::enable_connection_aborted"><span class="bold"><strong>enable_connection_aborted</strong></span></a> </p> </td> <td> <p> Socket option to report aborted connections on accept. </p> </td> </tr> <tr> <td> <p> <a class="link" href="endpoint_type.html" title="basic_socket::endpoint_type"><span class="bold"><strong>endpoint_type</strong></span></a> </p> </td> <td> <p> The endpoint type. </p> </td> </tr> <tr> <td> <p> <a class="link" href="implementation_type.html" title="basic_socket::implementation_type"><span class="bold"><strong>implementation_type</strong></span></a> </p> </td> <td> <p> The underlying implementation type of I/O object. </p> </td> </tr> <tr> <td> <p> <a class="link" href="keep_alive.html" title="basic_socket::keep_alive"><span class="bold"><strong>keep_alive</strong></span></a> </p> </td> <td> <p> Socket option to send keep-alives. </p> </td> </tr> <tr> <td> <p> <a class="link" href="linger.html" title="basic_socket::linger"><span class="bold"><strong>linger</strong></span></a> </p> </td> <td> <p> Socket option to specify whether the socket lingers on close if unsent data is present. </p> </td> </tr> <tr> <td> <p> <a class="link" href="lowest_layer_type.html" title="basic_socket::lowest_layer_type"><span class="bold"><strong>lowest_layer_type</strong></span></a> </p> </td> <td> <p> A basic_socket is always the lowest layer. </p> </td> </tr> <tr> <td> <p> <a class="link" href="message_flags.html" title="basic_socket::message_flags"><span class="bold"><strong>message_flags</strong></span></a> </p> </td> <td> <p> Bitmask type for flags that can be passed to send and receive operations. </p> </td> </tr> <tr> <td> <p> <a class="link" href="native_handle_type.html" title="basic_socket::native_handle_type"><span class="bold"><strong>native_handle_type</strong></span></a> </p> </td> <td> <p> The native representation of a socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="native_type.html" title="basic_socket::native_type"><span class="bold"><strong>native_type</strong></span></a> </p> </td> <td> <p> (Deprecated: Use native_handle_type.) The native representation of a socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="non_blocking_io.html" title="basic_socket::non_blocking_io"><span class="bold"><strong>non_blocking_io</strong></span></a> </p> </td> <td> <p> (Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="protocol_type.html" title="basic_socket::protocol_type"><span class="bold"><strong>protocol_type</strong></span></a> </p> </td> <td> <p> The protocol type. </p> </td> </tr> <tr> <td> <p> <a class="link" href="receive_buffer_size.html" title="basic_socket::receive_buffer_size"><span class="bold"><strong>receive_buffer_size</strong></span></a> </p> </td> <td> <p> Socket option for the receive buffer size of a socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="receive_low_watermark.html" title="basic_socket::receive_low_watermark"><span class="bold"><strong>receive_low_watermark</strong></span></a> </p> </td> <td> <p> Socket option for the receive low watermark. </p> </td> </tr> <tr> <td> <p> <a class="link" href="reuse_address.html" title="basic_socket::reuse_address"><span class="bold"><strong>reuse_address</strong></span></a> </p> </td> <td> <p> Socket option to allow the socket to be bound to an address that is already in use. </p> </td> </tr> <tr> <td> <p> <a class="link" href="send_buffer_size.html" title="basic_socket::send_buffer_size"><span class="bold"><strong>send_buffer_size</strong></span></a> </p> </td> <td> <p> Socket option for the send buffer size of a socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="send_low_watermark.html" title="basic_socket::send_low_watermark"><span class="bold"><strong>send_low_watermark</strong></span></a> </p> </td> <td> <p> Socket option for the send low watermark. </p> </td> </tr> <tr> <td> <p> <a class="link" href="service_type.html" title="basic_socket::service_type"><span class="bold"><strong>service_type</strong></span></a> </p> </td> <td> <p> The type of the service that will be used to provide I/O operations. </p> </td> </tr> <tr> <td> <p> <a class="link" href="shutdown_type.html" title="basic_socket::shutdown_type"><span class="bold"><strong>shutdown_type</strong></span></a> </p> </td> <td> <p> Different ways a socket may be shutdown. </p> </td> </tr> </tbody> </table></div> <h6> <a name="asio.reference.basic_socket.lowest_layer_type.h1"></a> <span><a name="asio.reference.basic_socket.lowest_layer_type.member_functions"></a></span><a class="link" href="lowest_layer_type.html#asio.reference.basic_socket.lowest_layer_type.member_functions">Member Functions</a> </h6> <div class="informaltable"><table class="table"> <colgroup> <col> <col> </colgroup> <thead><tr> <th> <p> Name </p> </th> <th> <p> Description </p> </th> </tr></thead> <tbody> <tr> <td> <p> <a class="link" href="assign.html" title="basic_socket::assign"><span class="bold"><strong>assign</strong></span></a> </p> </td> <td> <p> Assign an existing native socket to the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="async_connect.html" title="basic_socket::async_connect"><span class="bold"><strong>async_connect</strong></span></a> </p> </td> <td> <p> Start an asynchronous connect. </p> </td> </tr> <tr> <td> <p> <a class="link" href="at_mark.html" title="basic_socket::at_mark"><span class="bold"><strong>at_mark</strong></span></a> </p> </td> <td> <p> Determine whether the socket is at the out-of-band data mark. </p> </td> </tr> <tr> <td> <p> <a class="link" href="available.html" title="basic_socket::available"><span class="bold"><strong>available</strong></span></a> </p> </td> <td> <p> Determine the number of bytes available for reading. </p> </td> </tr> <tr> <td> <p> <a class="link" href="basic_socket.html" title="basic_socket::basic_socket"><span class="bold"><strong>basic_socket</strong></span></a> </p> </td> <td> <p> Construct a basic_socket without opening it. </p> <p> Construct and open a basic_socket. </p> <p> Construct a basic_socket, opening it and binding it to the given local endpoint. </p> <p> Construct a basic_socket on an existing native socket. </p> <p> Move-construct a basic_socket from another. </p> <p> Move-construct a basic_socket from a socket of another protocol type. </p> </td> </tr> <tr> <td> <p> <a class="link" href="bind.html" title="basic_socket::bind"><span class="bold"><strong>bind</strong></span></a> </p> </td> <td> <p> Bind the socket to the given local endpoint. </p> </td> </tr> <tr> <td> <p> <a class="link" href="cancel.html" title="basic_socket::cancel"><span class="bold"><strong>cancel</strong></span></a> </p> </td> <td> <p> Cancel all asynchronous operations associated with the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="close.html" title="basic_socket::close"><span class="bold"><strong>close</strong></span></a> </p> </td> <td> <p> Close the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="connect.html" title="basic_socket::connect"><span class="bold"><strong>connect</strong></span></a> </p> </td> <td> <p> Connect the socket to the specified endpoint. </p> </td> </tr> <tr> <td> <p> <a class="link" href="get_io_service.html" title="basic_socket::get_io_service"><span class="bold"><strong>get_io_service</strong></span></a> </p> </td> <td> <p> Get the io_service associated with the object. </p> </td> </tr> <tr> <td> <p> <a class="link" href="get_option.html" title="basic_socket::get_option"><span class="bold"><strong>get_option</strong></span></a> </p> </td> <td> <p> Get an option from the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="io_control.html" title="basic_socket::io_control"><span class="bold"><strong>io_control</strong></span></a> </p> </td> <td> <p> Perform an IO control command on the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="is_open.html" title="basic_socket::is_open"><span class="bold"><strong>is_open</strong></span></a> </p> </td> <td> <p> Determine whether the socket is open. </p> </td> </tr> <tr> <td> <p> <a class="link" href="local_endpoint.html" title="basic_socket::local_endpoint"><span class="bold"><strong>local_endpoint</strong></span></a> </p> </td> <td> <p> Get the local endpoint of the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="lowest_layer.html" title="basic_socket::lowest_layer"><span class="bold"><strong>lowest_layer</strong></span></a> </p> </td> <td> <p> Get a reference to the lowest layer. </p> <p> Get a const reference to the lowest layer. </p> </td> </tr> <tr> <td> <p> <a class="link" href="native.html" title="basic_socket::native"><span class="bold"><strong>native</strong></span></a> </p> </td> <td> <p> (Deprecated: Use native_handle().) Get the native socket representation. </p> </td> </tr> <tr> <td> <p> <a class="link" href="native_handle.html" title="basic_socket::native_handle"><span class="bold"><strong>native_handle</strong></span></a> </p> </td> <td> <p> Get the native socket representation. </p> </td> </tr> <tr> <td> <p> <a class="link" href="native_non_blocking.html" title="basic_socket::native_non_blocking"><span class="bold"><strong>native_non_blocking</strong></span></a> </p> </td> <td> <p> Gets the non-blocking mode of the native socket implementation. </p> <p> Sets the non-blocking mode of the native socket implementation. </p> </td> </tr> <tr> <td> <p> <a class="link" href="non_blocking.html" title="basic_socket::non_blocking"><span class="bold"><strong>non_blocking</strong></span></a> </p> </td> <td> <p> Gets the non-blocking mode of the socket. </p> <p> Sets the non-blocking mode of the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="open.html" title="basic_socket::open"><span class="bold"><strong>open</strong></span></a> </p> </td> <td> <p> Open the socket using the specified protocol. </p> </td> </tr> <tr> <td> <p> <a class="link" href="operator_eq_.html" title="basic_socket::operator="><span class="bold"><strong>operator=</strong></span></a> </p> </td> <td> <p> Move-assign a basic_socket from another. </p> <p> Move-assign a basic_socket from a socket of another protocol type. </p> </td> </tr> <tr> <td> <p> <a class="link" href="remote_endpoint.html" title="basic_socket::remote_endpoint"><span class="bold"><strong>remote_endpoint</strong></span></a> </p> </td> <td> <p> Get the remote endpoint of the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="set_option.html" title="basic_socket::set_option"><span class="bold"><strong>set_option</strong></span></a> </p> </td> <td> <p> Set an option on the socket. </p> </td> </tr> <tr> <td> <p> <a class="link" href="shutdown.html" title="basic_socket::shutdown"><span class="bold"><strong>shutdown</strong></span></a> </p> </td> <td> <p> Disable sends or receives on the socket. </p> </td> </tr> </tbody> </table></div> <h6> <a name="asio.reference.basic_socket.lowest_layer_type.h2"></a> <span><a name="asio.reference.basic_socket.lowest_layer_type.protected_member_functions"></a></span><a class="link" href="lowest_layer_type.html#asio.reference.basic_socket.lowest_layer_type.protected_member_functions">Protected Member Functions</a> </h6> <div class="informaltable"><table class="table"> <colgroup> <col> <col> </colgroup> <thead><tr> <th> <p> Name </p> </th> <th> <p> Description </p> </th> </tr></thead> <tbody> <tr> <td> <p> <a class="link" href="get_implementation.html" title="basic_socket::get_implementation"><span class="bold"><strong>get_implementation</strong></span></a> </p> </td> <td> <p> Get the underlying implementation of the I/O object. </p> </td> </tr> <tr> <td> <p> <a class="link" href="get_service.html" title="basic_socket::get_service"><span class="bold"><strong>get_service</strong></span></a> </p> </td> <td> <p> Get the service associated with the I/O object. </p> </td> </tr> <tr> <td> <p> <a class="link" href="_basic_socket.html" title="basic_socket::~basic_socket"><span class="bold"><strong>~basic_socket</strong></span></a> </p> </td> <td> <p> Protected destructor to prevent deletion through this type. </p> </td> </tr> </tbody> </table></div> <h6> <a name="asio.reference.basic_socket.lowest_layer_type.h3"></a> <span><a name="asio.reference.basic_socket.lowest_layer_type.data_members"></a></span><a class="link" href="lowest_layer_type.html#asio.reference.basic_socket.lowest_layer_type.data_members">Data Members</a> </h6> <div class="informaltable"><table class="table"> <colgroup> <col> <col> </colgroup> <thead><tr> <th> <p> Name </p> </th> <th> <p> Description </p> </th> </tr></thead> <tbody> <tr> <td> <p> <a class="link" href="max_connections.html" title="basic_socket::max_connections"><span class="bold"><strong>max_connections</strong></span></a> </p> </td> <td> <p> The maximum length of the queue of pending incoming connections. </p> </td> </tr> <tr> <td> <p> <a class="link" href="message_do_not_route.html" title="basic_socket::message_do_not_route"><span class="bold"><strong>message_do_not_route</strong></span></a> </p> </td> <td> <p> Specify that the data should not be subject to routing. </p> </td> </tr> <tr> <td> <p> <a class="link" href="message_end_of_record.html" title="basic_socket::message_end_of_record"><span class="bold"><strong>message_end_of_record</strong></span></a> </p> </td> <td> <p> Specifies that the data marks the end of a record. </p> </td> </tr> <tr> <td> <p> <a class="link" href="message_out_of_band.html" title="basic_socket::message_out_of_band"><span class="bold"><strong>message_out_of_band</strong></span></a> </p> </td> <td> <p> Process out-of-band data. </p> </td> </tr> <tr> <td> <p> <a class="link" href="message_peek.html" title="basic_socket::message_peek"><span class="bold"><strong>message_peek</strong></span></a> </p> </td> <td> <p> Peek at incoming data without removing it from the input queue. </p> </td> </tr> </tbody> </table></div> <h6> <a name="asio.reference.basic_socket.lowest_layer_type.h4"></a> <span><a name="asio.reference.basic_socket.lowest_layer_type.protected_data_members"></a></span><a class="link" href="lowest_layer_type.html#asio.reference.basic_socket.lowest_layer_type.protected_data_members">Protected Data Members</a> </h6> <div class="informaltable"><table class="table"> <colgroup> <col> <col> </colgroup> <thead><tr> <th> <p> Name </p> </th> <th> <p> Description </p> </th> </tr></thead> <tbody> <tr> <td> <p> <a class="link" href="implementation.html" title="basic_socket::implementation"><span class="bold"><strong>implementation</strong></span></a> </p> </td> <td> <p> (Deprecated: Use get_implementation().) The underlying implementation of the I/O object. </p> </td> </tr> <tr> <td> <p> <a class="link" href="service.html" title="basic_socket::service"><span class="bold"><strong>service</strong></span></a> </p> </td> <td> <p> (Deprecated: Use get_service().) The service associated with the I/O object. </p> </td> </tr> </tbody> </table></div> <p> The <a class="link" href="../basic_socket.html" title="basic_socket"><code class="computeroutput"><span class="identifier">basic_socket</span></code></a> class template provides functionality that is common to both stream-oriented and datagram-oriented sockets. </p> <h6> <a name="asio.reference.basic_socket.lowest_layer_type.h5"></a> <span><a name="asio.reference.basic_socket.lowest_layer_type.thread_safety"></a></span><a class="link" href="lowest_layer_type.html#asio.reference.basic_socket.lowest_layer_type.thread_safety">Thread Safety</a> </h6> <p> <span class="emphasis"><em>Distinct</em></span> <span class="emphasis"><em>objects:</em></span> Safe. </p> <p> <span class="emphasis"><em>Shared</em></span> <span class="emphasis"><em>objects:</em></span> Unsafe. </p> <h6> <a name="asio.reference.basic_socket.lowest_layer_type.h6"></a> <span><a name="asio.reference.basic_socket.lowest_layer_type.requirements"></a></span><a class="link" href="lowest_layer_type.html#asio.reference.basic_socket.lowest_layer_type.requirements">Requirements</a> </h6> <p> <span class="emphasis"><em>Header: </em></span><code class="literal">asio/basic_socket.hpp</code> </p> <p> <span class="emphasis"><em>Convenience header: </em></span><code class="literal">asio.hpp</code> </p> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2013 Christopher M. Kohlhoff<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="lowest_layer/overload2.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../basic_socket.html"><img src="../../../up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../home.png" alt="Home"></a><a accesskey="n" href="max_connections.html"><img src="../../../next.png" alt="Next"></a> </div> </body> </html>
laeotropic/HTTP-Proxy
deps/asio-1.10.1/doc/asio/reference/basic_socket/lowest_layer_type.html
HTML
bsd-2-clause
30,585
<?php /** * contains the F51InfosysCollaborator class * * @category * @package * @author Peter <pel@intern1.dk> */ require_once F51_DIR . 'wpinfosysconnector.php'; /** * F51 Infosys Collaboration class * * @category * @package * @author Peter <pel@intern1.dk> */ class F51InfosysCollaborator { /** * instance of the InfosysConnector class * * @var InfosysConnector */ private $infosys_connector; /** * method docblock * * @access public * @return void */ public function init() { /** * plugin setup/install */ register_activation_hook(__FILE__, array($this, 'pluginActivation')); register_deactivation_hook(__FILE__, array($this, 'pluginDeactivation')); /** * setting up hooks */ add_action('plugins_loaded', array($this, 'setupHooks')); add_action('parse_request', array($this, 'parseRequest')); add_action('query_vars', array($this, 'queryVars')); } /** * handles request parsing to cut in on requests * for this plugin * * @access public * @return void */ public function parseRequest($wp) { if (isset($wp->query_vars['f51-ajax'])) { switch($wp->query_vars['f51-ajax']) { case 'activity-structure': $this->presentActivityAsJSON(!empty($wp->query_vars['f51-activity-id']) ? $wp->query_vars['f51-activity-id'] : 0); exit; case 'create-activity': $this->createActivity(); exit; } } } /** * registers 'f51' as a recognized query var * * @param array $query_vars Array of recognized query vars * * @access public * @return array */ public function queryVars($query_vars) { $query_vars[] = 'f51-ajax'; $query_vars[] = 'f51-activity-id'; return $query_vars; } /** * handles plugin install with default settings/options * * @return void */ public function pluginActivation() { if (version_compare(get_bloginfo('version'), '3.4', '<')) { deactivate_plugins(basename(__FILE__)); } else { $options = array( 'infosys-url' => 'http://infosys-url/', 'authentication-user' => 'Infosys auth user', 'authentication-code' => 'Infosys auth code', ); update_option('f51_infosys_options', $options); } } /** * handles plugin uninstall * * @return void */ public function pluginDeactivation() { delete_option('f51_infosys_options'); } /** * hooks */ /** * sets up various hooks needed for functionality * * @return void */ public function setupHooks() { add_action('init', array($this, 'initHook')); if (is_admin()) { add_action('admin_init', array($this, 'adminInitHook')); add_action('admin_menu', array($this, 'adminMenuHook')); add_action('add_meta_boxes', array($this, 'metaBoxHook')); } } /** * runs on wp init * * @return void */ public function initHook() { // add con activity type as post register_post_type('activity', array( // 'capability_type' => 'activity', 'exclude_from_search' => true, 'description' => 'RPG activity', 'labels' => array( 'name' => 'RPG Activities', 'singular_name' => 'RPG Activity', ), 'publicly_queryable' => true, 'rewrite' => array( 'slug' => 'aktivitet', 'with_front' => false, ), 'taxonomies' => array( 'category', 'post_tag', ), 'show_ui' => true, 'supports' => array( 'custom_fields', 'editor', 'excerpt', 'query_var', 'revisions', 'title', ), )); } /** * adds a meta box for allowing editing of infosys data * * @param object $post Post object representing page viewed * * @access public * @return void */ public function metaBoxHook() { add_meta_box( 'f51-infosys-meta', 'Infosys Collaboration', array($this, 'renderMetaBox'), 'activity', 'normal', 'high' ); } /** * renders the meta box for editing infosys data * * @param object $post Post object * * @access public * @return void */ public function renderMetaBox($post) { $infosys_url = get_option('infosys-url'); if (substr($infosys_url, -1) !== '/') { $infosys_url .= '/'; } if (!preg_match('*^https?://*i', $infosys_url)) { $infosys_url = 'http://' . $infosys_url; } require F51_TEMPLATES_DIR . 'metaboxes.phtml'; } /** * registers settings and other stuff that needs to * take place during the admin init hook * * @access public * @return void */ public function adminInitHook() { register_setting('f51_infosys_options', 'infosys-url'); register_setting('f51_infosys_options', 'authentication-user'); register_setting('f51_infosys_options', 'authentication-code'); wp_enqueue_style('f51-stylesheet', plugins_url('f51-infosys/css/f51.css')); } /** * runs pre admin menu render and adds settings link * * @return void */ public function adminMenuHook() { add_options_page( 'Infosys Collaboration settings', // title 'Infosys Collaboration', // menu link title 'manage_options', 'f51_infosys_admin_settings', array($this, 'adminSettingsPage') ); } /** * method docblock * * @param * * @access public * @return void */ public function adminSettingsPage() { require F51_TEMPLATES_DIR . 'settings_page.phtml'; } /** * returns an infosys connector * * @access protected * @return InfosysConnector */ protected function getInfosysConnector() { if (empty($this->infosys_connector)) { $this->infosys_connector = new WPInfosysConnector(get_option('infosys-url'), get_option('authentication-user'), get_option('authentication-code')); } return $this->infosys_connector; } /** * fetches the activity structure from infosys and * returns it to the ajax request * * @param int $activity_id Optional ID of activity being worked on * * @access protected * @return void */ protected function presentActivityAsJSON($activity_id) { $activity = $this->retrieveActivityStructure($activity_id); require F51_TEMPLATES_DIR . 'ajax/metaboxes.phtml'; } /** * fetches the activity structure from infosys and * returns it to the ajax request * * @param int $activity_id Optional ID of activity being worked on * * @access public * @return void */ public function retrieveActivityStructure($activity_id) { $connector = $this->getInfosysConnector(); $activity_structure = $connector->getActivityStructure(); $activity = $connector->findActivity('wp_link', $activity_id); return $activity; } /** * calls the infosys service to create an activity * or update it * * @access protected * @return void */ protected function createActivity() { if (empty($_POST['id'])) { throw new Exception('Lacking activity data'); } $data = $_POST; $data['wp_link'] = $data['id']; $data['foromtale'] = empty($_POST['foromtale']) ? '' : strip_tags($_POST['foromtale']); unset($data['id']); $connector = $this->getInfosysConnector(); $connector->saveActivity($data, $connector->findActivity('wp_link', $data['wp_link'])); } }
Fake51/f51-infosys
f51-infosys/f51infosyscollaborator.php
PHP
bsd-2-clause
8,511
{% comment %} This form template is meant to be used with the "include" template tag. {% endcomment %} <fieldset> <legend class="small">General Information</legend> {% include "form_generic.html" with form=sourceForm.fieldsets.general_info %} </fieldset> <fieldset> <legend class="small">Location Keys</legend> <span class="helptext_long"> This is how you organize your source's images. Location keys are a hierarchy of categories. As the name suggests, location keys typically refer to the location where the image was taken, but this is not strictly required. Here's an example:<br /><br /> Suppose you take your coral images at 3 different islands: North, South, and East. At each island, you take photos at 3 different coral habitats based on their distance from the shore: Fringing Reef, 5m out, and 10m out. For each island + habitat combination, you have multiple images with no particular organization to them.<br /><br /> In this case you would have 3 location keys: Key 1 would be Island, Key 2 would be Habitat, and Key 3 would be something arbitrary to differentiate between images, like Number. When you upload an image, you'll specify the "location values" that correspond to each of these keys. For example, one image may have the values North, 5m out, and 4, indicating that it's the 4th image that is from North island at 5m out.<br /><br /> {% if source_form_type == "new" %} You can have 1 to 5 location keys, depending on how much organization you need. Once you've uploaded some images, you'll be able to search through them using location values: you can search for all the images that are from the North island, all the images that are from the South island's fringing reef, and so on.<br /><br /> NOTE: Once you create your source, you cannot change the number of location keys. You'll only be able to change the keys' names. So please take the time now to think carefully about the organization of your source. NOTE2: The image acquisition date is always part of the image metadata, along with several other fields, such as camera, water quality etc. There is therefore no need to use e.g. 'year' as a location key. {% else %} {# edit #} Once you've uploaded some images, you'll be able to search through them using location values: you can search for all the images that are from the North island, all the images that are from the South island's fringing reef, and so on.<br /><br /> NOTE: Since you are editing a source that's already been created, you cannot change the number of location keys. You can only change the keys' names. {% endif %} </span> {% include "form_generic.html" with form=location_key_form %} </fieldset> <fieldset> <legend class="small">Image Annotation</legend> <legend class="smaller">Default image height</legend> <span class="helptext">{{ sourceForm.image_height_in_cm.help_text|linebreaksbr }}</span> {% include "form_generic_one_field.html" with field=sourceForm.image_height_in_cm dont_show_help_text="True" %} <hr class="light"/> <legend class="smaller">Default image annotation area</legend> <span class="helptext">{{ annotationAreaForm.form_help_text|linebreaksbr }}</span> {% include "annotations/form_annotation_area.html" with form=annotationAreaForm type="percent" %} <hr class="light"/> <legend class="smaller">Point generation method</legend> <span class="helptext">{{ pointGenForm.form_help_text|linebreaksbr }}</span> {% include "form_generic.html" with form=pointGenForm %} {# Careful with boolean short-circuiting - 'source' is only available if we are editing a source. #} {% if source_form_type == "edit" and not source.enable_robot_classifier %} <hr class="light"/> <legend class="smaller">Machine annotation</legend> <span class="helptext"> Status: Disabled. If you wish to enable machine annotation for this source, please <a href="{% url contact %}" target="_blank">contact us</a>. </span> {% endif %} {% if source_form_type == "new" or source.enable_robot_classifier %} <hr class="light"/> <legend class="smaller">Level of alleviation</legend> <span class="helptext_long"> The CoralNet alleviate feature offers a trade-off between fully automated and fully manual annotation. This is done by auto-accepting machine annotations when they are sufficiently confident. Please refer to our <a href="https://vimeo.com/channels/coralnet/133397508"> instruction video</a> for an overview and <a href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0130312">this study</a> for more details.<br/><br/> This auto-acceptance happens when you enter the annotation tool for an image. Effectively, the machine's most confident points are "alleviated" from your annotation workload (for that image). Alleviated annotation decisions are treated as 'Confirmed', and are included when you export your annotations. <br/><br/> Users control this functionality by specifying the level of alleviation. For example, with 40% alleviation, the machine learning algorithm ("robot") will do 40% of the point annotations and leave the remaining 60% for the human operator. This level of alleviation is NOT per image, but the average across all remaining images. Some (easy) images may be fully alleviated, while other (harder) may have very little alleviated points. 0% alleviation corresponds to no alleviation (i.e. fully manual annotation).<br/><br/> When the first robot version is trained for your source, you can see the trade-off between the level of alleviation and the annotation accuracy. We recommend that you set the alleviation level to 0% until you have seen this trade-off curve. You can then adjust the alleviation level. <br/><br/> <a href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0130312">This study</a> suggests that a 5% drop is annotation accuracy has marginal (if any) impact on derived cover estimates. We therefore suggest that you set the level of alleviation corresponding to a 5% drop in accuracy.<br/><br/> NOTE1: The level of alleviation should not be confused with the confidence scores that are displayed during manual annotation. Once you set your desired level of alleviation, this is translated to a confidence score by the back-end, and any robot prediction above that confidence will be automatically accepted. <br/><br/> NOTE2: Machine annotations that have <strong>not</strong> been Confirmed can optionally also be included in your export (see the 'export' page) <br/><br/> </span> {% include "form_generic_one_field.html" with field=sourceForm.alleviate_threshold dont_show_help_text="True" %} {% endif %} </fieldset> <fieldset> <legend class="small">World Location</legend> <span class="helptext">To get your source's coordinates, try <a href="http://www.latlong.net/" target="_blank">latlong.net</a>.<br /> Later, we'll use this information to integrate with Google Maps.</span> {% include "form_generic.html" with form=sourceForm.fieldsets.world_location %} </fieldset>
DevangS/CoralNet
templates/images/form_source.html
HTML
bsd-2-clause
7,563
/* Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 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 OWNER 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. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ using System; using System.Diagnostics; namespace MatterHackers.Agg.UI { public class SimpleTextTabWidget : Tab { public SimpleTextTabWidget(TabPage tabPageControledByTab, string internalTabName) : this(tabPageControledByTab, internalTabName, 12, RGBA_Bytes.DarkGray, RGBA_Bytes.White, RGBA_Bytes.Black, RGBA_Bytes.White) { } public SimpleTextTabWidget(TabPage tabPageControledByTab, string internalTabName, double pointSize, RGBA_Bytes selectedTextColor, RGBA_Bytes selectedBackgroundColor, RGBA_Bytes normalTextColor, RGBA_Bytes normalBackgroundColor) : base(internalTabName, new GuiWidget(), new GuiWidget(), new GuiWidget(), tabPageControledByTab) { AddText(tabPageControledByTab.Text, selectedWidget, selectedTextColor, selectedBackgroundColor, pointSize); AddText(tabPageControledByTab.Text, normalWidget, normalTextColor, normalBackgroundColor, pointSize); //hoverWidget; tabPageControledByTab.TextChanged += new EventHandler(tabPageControledByTab_TextChanged); SetBoundsToEncloseChildren(); } public override void OnMouseDown(MouseEventArgs mouseEvent) { OnSelected(mouseEvent); base.OnMouseDown(mouseEvent); } private void tabPageControledByTab_TextChanged(object sender, EventArgs e) { normalWidget.Children[0].Text = ((GuiWidget)sender).Text; normalWidget.SetBoundsToEncloseChildren(); selectedWidget.Children[0].Text = ((GuiWidget)sender).Text; selectedWidget.SetBoundsToEncloseChildren(); SetBoundsToEncloseChildren(); } public TextWidget tabTitle; private void AddText(string tabText, GuiWidget widgetState, RGBA_Bytes textColor, RGBA_Bytes backgroundColor, double pointSize) { tabTitle = new TextWidget(tabText, pointSize: pointSize, textColor: textColor); tabTitle.AutoExpandBoundsToText = true; widgetState.AddChild(tabTitle); widgetState.Selectable = false; widgetState.SetBoundsToEncloseChildren(); widgetState.BackgroundColor = backgroundColor; } } public abstract class Tab : GuiWidget { private RGBA_Bytes backgroundColor = new RGBA_Bytes(230, 230, 230); private TabPage tabPageControledByTab; protected GuiWidget normalWidget; protected GuiWidget hoverWidget; protected GuiWidget selectedWidget; public event EventHandler Selected; public Tab(string tabName, GuiWidget normalWidget, GuiWidget hoverWidget, GuiWidget pressedWidget, TabPage tabPageControledByTab) { base.Name = tabName; this.normalWidget = normalWidget; this.hoverWidget = hoverWidget; this.selectedWidget = pressedWidget; AddChild(normalWidget); AddChild(hoverWidget); hoverWidget.Visible = false; AddChild(pressedWidget); pressedWidget.Visible = false; Padding = new BorderDouble(5, 3, 20, 3); this.tabPageControledByTab = tabPageControledByTab; SetBoundsToEncloseChildren(); } public override void OnParentChanged(EventArgs e) { TabBarContaningTab.TabIndexChanged += SelectionChanged; base.OnParentChanged(e); } public virtual void OnSelected(EventArgs e) { if (Selected != null) { Selected(this, e); } } public void SelectionChanged(object sender, EventArgs e) { if (TabBarContaningTab != null) { bool selected = TabPageControlledByTab == TabBarContaningTab.GetActivePage(); if (selected) { normalWidget.Visible = false; hoverWidget.Visible = false; selectedWidget.Visible = true; } else { normalWidget.Visible = true; hoverWidget.Visible = false; selectedWidget.Visible = false; } } } public TabBar TabBarContaningTab { get { return (TabBar)Parent; } } public TabPage TabPageControlledByTab { get { return tabPageControledByTab; } } public override string Name { set { // You should not change this it is required for the interface to this tab. GuiWidget.BreakInDebugger(); } } public override string Text { get { throw new Exception("You are probably looking for the Name not the text of a tab."); } set { throw new Exception("You are probably looking for the Name not the text of a tab."); } } } }
mmoening/agg-sharp
Gui/TabControl/Tab.cs
C#
bsd-2-clause
5,674
require "language/go" class Packer < Formula desc "Tool for creating identical machine images for multiple platforms" homepage "https://packer.io" url "https://github.com/mitchellh/packer.git", :tag => "v0.10.0", :revision => "fedb0e21f03607060b002fd1467bc617b6a4e812" revision 1 bottle do cellar :any_skip_relocation sha256 "18ead2ff2d417a45c09a52a91c61f1fa33b7496280d11b6027b5ddb669e25b84" => :el_capitan sha256 "4b4b2fccb5c68ec5fbdb24d0a59bf408070ad2435d288e02c0386b8a06674aa4" => :yosemite sha256 "491456a64219b8eced0793cfdf07c58860ea12fe5f1368b94d2bc0236db41350" => :mavericks end depends_on :hg => :build depends_on "go" => :build go_resource "github.com/mitchellh/gox" do url "https://github.com/mitchellh/gox.git", :revision => "ef1967b9f538fe467e6a82fc42ec5dff966ad4ea" end go_resource "github.com/aws/aws-sdk-go" do url "https://github.com/aws/aws-sdk-go.git", :revision => "8041be5461786460d86b4358305fbdf32d37cfb2" end go_resource "github.com/jmespath/go-jmespath" do url "https://github.com/jmespath/go-jmespath.git", :revision => "c01cf91b011868172fdcd9f41838e80c9d716264" end go_resource "github.com/dylanmei/winrmtest" do url "https://github.com/dylanmei/winrmtest.git", :revision => "025617847eb2cf9bd1d851bc3b22ed28e6245ce5" end go_resource "github.com/masterzen/winrm" do url "https://github.com/masterzen/winrm.git", :revision => "54ea5d01478cfc2afccec1504bd0dfcd8c260cfa" end go_resource "github.com/masterzen/simplexml" do url "https://github.com/masterzen/simplexml.git", :revision => "95ba30457eb1121fa27753627c774c7cd4e90083" end go_resource "github.com/satori/go.uuid" do url "https://github.com/satori/go.uuid.git", :revision => "d41af8bb6a7704f00bc3b7cba9355ae6a5a80048" end go_resource "github.com/nu7hatch/gouuid" do url "https://github.com/nu7hatch/gouuid.git", :revision => "179d4d0c4d8d407a32af483c2354df1d2c91e6c3" end go_resource "github.com/packer-community/winrmcp" do url "https://github.com/packer-community/winrmcp.git", :revision => "3d184cea22ee1c41ec1697e0d830ff0c78f7ea97" end go_resource "github.com/dylanmei/iso8601" do url "https://github.com/dylanmei/iso8601.git", :revision => "2075bf119b58e5576c6ed9f867b8f3d17f2e54d4" end go_resource "github.com/digitalocean/godo" do url "https://github.com/digitalocean/godo.git", :revision => "6ca5b770f203b82a0fca68d0941736458efa8a4f" end go_resource "github.com/google/go-querystring" do url "https://github.com/google/go-querystring.git", :revision => "2a60fc2ba6c19de80291203597d752e9ba58e4c0" end go_resource "github.com/tent/http-link-go" do url "https://github.com/tent/http-link-go.git", :revision => "ac974c61c2f990f4115b119354b5e0b47550e888" end go_resource "github.com/go-ini/ini" do url "https://github.com/go-ini/ini.git", :revision => "afbd495e5aaea13597b5e14fe514ddeaa4d76fc3" end go_resource "gopkg.in/fsnotify.v1" do url "https://github.com/go-fsnotify/fsnotify.git", :revision => "8611c35ab31c1c28aa903d33cf8b6e44a399b09e" end go_resource "github.com/rackspace/gophercloud" do url "https://github.com/rackspace/gophercloud.git", :revision => "680aa02616313d8399abc91f17a444cf9292f0e1" end go_resource "github.com/klauspost/pgzip" do url "https://github.com/klauspost/pgzip.git", :revision => "47f36e165cecae5382ecf1ec28ebf7d4679e307d" end go_resource "github.com/klauspost/compress" do url "https://github.com/klauspost/compress.git", :revision => "f86d2e6d8a77c6a2c4e42a87ded21c6422f7557e" end go_resource "github.com/klauspost/cpuid" do url "https://github.com/klauspost/cpuid.git", :revision => "349c675778172472f5e8f3a3e0fe187e302e5a10" end go_resource "github.com/klauspost/crc32" do url "https://github.com/klauspost/crc32.git", :revision => "999f3125931f6557b991b2f8472172bdfa578d38" end go_resource "github.com/pierrec/lz4" do url "https://github.com/pierrec/lz4.git", :revision => "383c0d87b5dd7c090d3cddefe6ff0c2ffbb88470" end go_resource "github.com/pierrec/xxHash" do url "https://github.com/pierrec/xxHash.git", :revision => "5a004441f897722c627870a981d02b29924215fa" end go_resource "github.com/masterzen/xmlpath" do url "https://github.com/masterzen/xmlpath.git", :revision => "13f4951698adc0fa9c1dda3e275d489a24201161" end go_resource "github.com/mitchellh/iochan" do url "https://github.com/mitchellh/iochan.git", :revision => "87b45ffd0e9581375c491fef3d32130bb15c5bd7" end go_resource "github.com/hashicorp/atlas-go" do url "https://github.com/hashicorp/atlas-go.git", :revision => "0008886ebfa3b424bed03e2a5cbe4a2568ea0ff6" end go_resource "github.com/hashicorp/go-checkpoint" do url "https://github.com/hashicorp/go-checkpoint.git", :revision => "e4b2dc34c0f698ee04750bf2035d8b9384233e1b" end go_resource "github.com/hashicorp/go-msgpack" do url "https://github.com/hashicorp/go-msgpack.git", :revision => "fa3f63826f7c23912c15263591e65d54d080b458" end go_resource "github.com/hashicorp/go-multierror" do url "https://github.com/hashicorp/go-multierror.git", :revision => "d30f09973e19c1dfcd120b2d9c4f168e68d6b5d5" end go_resource "github.com/hashicorp/go-version" do url "https://github.com/hashicorp/go-version.git", :revision => "7e3c02b30806fa5779d3bdfc152ce4c6f40e7b38" end go_resource "github.com/hashicorp/yamux" do url "https://github.com/hashicorp/yamux.git", :revision => "df949784da9ed028ee76df44652e42d37a09d7e4" end go_resource "github.com/mitchellh/cli" do url "https://github.com/mitchellh/cli.git", :revision => "5c87c51cedf76a1737bf5ca3979e8644871598a6" end go_resource "github.com/mitchellh/mapstructure" do url "https://github.com/mitchellh/mapstructure.git", :revision => "281073eb9eb092240d33ef253c404f1cca550309" end go_resource "github.com/kardianos/osext" do url "https://github.com/kardianos/osext.git", :revision => "29ae4ffbc9a6fe9fb2bc5029050ce6996ea1d3bc" end go_resource "github.com/mitchellh/panicwrap" do url "https://github.com/mitchellh/panicwrap.git", :revision => "a1e50bc201f387747a45ffff020f1af2d8759e88" end go_resource "github.com/mitchellh/prefixedio" do url "https://github.com/mitchellh/prefixedio.git", :revision => "6e6954073784f7ee67b28f2d22749d6479151ed7" end go_resource "github.com/mitchellh/reflectwalk" do url "https://github.com/mitchellh/reflectwalk.git", :revision => "eecf4c70c626c7cfbb95c90195bc34d386c74ac6" end go_resource "github.com/mitchellh/go-fs" do url "https://github.com/mitchellh/go-fs.git", :revision => "a34c1b9334e86165685a9449b782f20465eb8c69" end go_resource "github.com/mitchellh/goamz" do url "https://github.com/mitchellh/goamz.git", :revision => "caaaea8b30ee15616494ee68abd5d8ebbbef05cf" end go_resource "github.com/mitchellh/multistep" do url "https://github.com/mitchellh/multistep.git", :revision => "162146fc57112954184d90266f4733e900ed05a5" end go_resource "code.google.com/p/gosshold" do url "https://code.google.com/p/gosshold/", :using => :hg, :revision => "9dd3b6b6e7b3e1b7f30c2b58c5ec5fff6bf9feff" end go_resource "github.com/ActiveState/tail" do url "https://github.com/ActiveState/tail.git", :revision => "1a0242e795eeefe54261ff308dc685f7d29cc58c" end go_resource "google.golang.org/api" do url "https://github.com/google/google-api-go-client.git", :revision => "ddff2aff599105a55549cf173852507dfa094b7f" end go_resource "golang.org/x/crypto" do url "https://go.googlesource.com/crypto.git", :revision => "81bf7719a6b7ce9b665598222362b50122dfc13b" end go_resource "golang.org/x/oauth2" do url "https://go.googlesource.com/oauth2.git", :revision => "8a57ed94ffd43444c0879fe75701732a38afc985" end go_resource "golang.org/x/net" do url "https://go.googlesource.com/net.git", :revision => "6ccd6698c634f5d835c40c1c31848729e0cecda1" end go_resource "google.golang.org/appengine" do url "https://github.com/golang/appengine.git", :revision => "6bde959377a90acb53366051d7d587bfd7171354" end go_resource "google.golang.org/cloud" do url "https://github.com/GoogleCloudPlatform/gcloud-golang.git", :revision => "5a3b06f8b5da3b7c3a93da43163b872c86c509ef" end go_resource "github.com/golang/protobuf" do url "https://github.com/golang/protobuf.git", :revision => "b982704f8bb716bb608144408cff30e15fbde841" end go_resource "github.com/mitchellh/gophercloud-fork-40444fb" do url "https://github.com/mitchellh/gophercloud-fork-40444fb.git", :revision => "40444fbc2b10960682b34e6822eb9179216e1ae1" end go_resource "github.com/racker/perigee" do url "https://github.com/racker/perigee.git", :revision => "44a7879d89b7040bcdb51164a83292ef5bf9deec" end go_resource "github.com/going/toolkit" do url "https://github.com/going/toolkit.git", :revision => "5bff591dc40da25dcc875d3fa1a3373d74d45411" end go_resource "github.com/mitchellh/go-vnc" do url "https://github.com/mitchellh/go-vnc.git", :revision => "723ed9867aed0f3209a81151e52ddc61681f0b01" end go_resource "github.com/howeyc/fsnotify" do url "https://github.com/howeyc/fsnotify.git", :revision => "4894fe7efedeeef21891033e1cce3b23b9af7ad2" end go_resource "gopkg.in/tomb.v1" do url "https://gopkg.in/tomb.v1.git", :revision => "dd632973f1e7218eb1089048e0798ec9ae7dceb8" end go_resource "github.com/vaughan0/go-ini" do url "https://github.com/vaughan0/go-ini.git", :revision => "a98ad7ee00ec53921f08832bc06ecf7fd600e6a1" end go_resource "github.com/armon/go-radix" do url "https://github.com/armon/go-radix.git", :revision => "4239b77079c7b5d1243b7b4736304ce8ddb6f0f2" end go_resource "github.com/bgentry/speakeasy" do url "https://github.com/bgentry/speakeasy.git", :revision => "36e9cfdd690967f4f690c6edcc9ffacd006014a0" end go_resource "github.com/hashicorp/errwrap" do url "https://github.com/hashicorp/errwrap.git", :revision => "7554cd9344cec97297fa6649b055a8c98c2a1e55" end go_resource "github.com/hashicorp/go-cleanhttp" do url "https://github.com/hashicorp/go-cleanhttp.git", :revision => "875fb671b3ddc66f8e2f0acc33829c8cb989a38d" end go_resource "github.com/hpcloud/tail" do url "https://github.com/hpcloud/tail.git", :revision => "1a0242e795eeefe54261ff308dc685f7d29cc58c" end go_resource "github.com/kr/fs" do url "https://github.com/kr/fs.git", :revision => "2788f0dbd16903de03cb8186e5c7d97b69ad387b" end go_resource "github.com/mattn/go-isatty" do url "https://github.com/mattn/go-isatty.git", :revision => "56b76bdf51f7708750eac80fa38b952bb9f32639" end go_resource "github.com/mitchellh/go-homedir" do url "https://github.com/mitchellh/go-homedir.git", :revision => "d682a8f0cf139663a984ff12528da460ca963de9" end go_resource "github.com/pkg/sftp" do url "https://github.com/pkg/sftp.git", :revision => "e84cc8c755ca39b7b64f510fe1fffc1b51f210a5" end go_resource "github.com/ugorji/go" do url "https://github.com/ugorji/go.git", :revision => "646ae4a518c1c3be0739df898118d9bccf993858" end go_resource "golang.org/x/sys" do url "https://go.googlesource.com/sys", :revision => "50c6bc5e4292a1d4e65c6e9be5f53be28bcbe28e" end go_resource "gopkg.in/xmlpath.v2" do url "https://gopkg.in/xmlpath.v2.git", :revision => "860cbeca3ebcc600db0b213c0e83ad6ce91f5739" end def install ENV["XC_OS"] = OS::NAME ENV["XC_ARCH"] = MacOS.prefer_64_bit? ? "amd64" : "386" ENV["GOPATH"] = buildpath # For the gox buildtool used by packer, which doesn't need to # get installed permanently ENV.append_path "PATH", buildpath packerpath = buildpath/"src/github.com/mitchellh/packer" packerpath.install Dir["{*,.git}"] Language::Go.stage_deps resources, buildpath/"src" mkdir_p buildpath/"bin" cd "src/github.com/mitchellh/gox" do system "go", "build" buildpath.install "gox" end cd "src/github.com/mitchellh/packer" do system "make", "bin" bin.install Dir["bin/*"] zsh_completion.install "contrib/zsh-completion/_packer" end end test do minimal = testpath/"minimal.json" minimal.write <<-EOS.undent { "builders": [{ "type": "amazon-ebs", "region": "us-east-1", "source_ami": "ami-59a4a230", "instance_type": "m3.medium", "ssh_username": "ubuntu", "ami_name": "homebrew packer test {{timestamp}}" }], "provisioners": [{ "type": "shell", "inline": [ "sleep 30", "sudo apt-get update" ] }] } EOS system "#{bin}/packer", "validate", minimal end end
forevergenin/homebrew-core
Formula/packer.rb
Ruby
bsd-2-clause
13,245
-------------------------------------------------- ### Summary of Folder Structure and File Contents Last updated: July 19, 2018 -------------------------------------------------- **Language** - Contains the base for the Drasil language README.md - This file drasil-lang.cabal - Cabal file, used by stack to build drasil-lang stack.yaml - Used by Stack
JacquesCarette/literate-scientific-software
code/drasil-lang/README.md
Markdown
bsd-2-clause
365
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #pragma once #include "AssetTypeActions_Base.h" class FAssetTypeActions_Blackboard : public FAssetTypeActions_Base { public: // IAssetTypeActions Implementation virtual FText GetName() const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_Blackboard", "Blackboard"); } virtual FColor GetTypeColor() const override { return FColor(201, 29, 85); } virtual UClass* GetSupportedClass() const override; virtual void OpenAssetEditor( const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor = TSharedPtr<IToolkitHost>() ) override; virtual uint32 GetCategories() override; };
PopCap/GameIdea
Engine/Source/Editor/BehaviorTreeEditor/Private/AssetTypeActions_Blackboard.h
C
bsd-2-clause
687
/* Copyright (c) 2013, Regents of the Columbia University * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * * 2. 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. * * 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. */ // RUN: %srcroot/test/runtime/run-scheduler-test.py %s -gxx "%gxx" -objroot "%objroot" -ternruntime "%ternruntime" -ternannotlib "%ternannotlib" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int main(int argc, char *argv[], char *env[]) { char buf0[64], buf1[64], buf2[64]; sprintf(buf1, "this is a test. "); sprintf(buf2, "another test."); strcpy(buf0, buf1); strcat(buf0, buf2); printf("%s\n", buf0); pthread_mutex_lock(&m); pthread_mutex_unlock(&m); return 0; } // CHECK indicates expected output checked by FileCheck; auto-generated by appending -gen to the RUN command above. // CHECK: this is a test. another test.
hemingcui/xtern_with_paxos
test/runtime/tmp-tests/one-thread-test.cpp
C++
bsd-2-clause
2,095
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Security.Cryptography; using System.Text; using System.Windows.Forms; using DeOps.Implementation; using DeOps.Services.Trust; namespace DeOps.Services.Profile { public partial class EditProfile : DeOps.Interface.CustomIconForm { public OpCore Core; TrustService Links; public ProfileService Profiles; public ProfileView MainView; List<ProfileTemplate> Templates = new List<ProfileTemplate>(); public Dictionary<string, string> TextFields = new Dictionary<string, string>(); public Dictionary<string, string> FileFields = new Dictionary<string, string>(); public EditProfile(ProfileService control, ProfileView view) { InitializeComponent(); Core = control.Core; Links = Core.Trust; Profiles = control; MainView = view; TextFields = new Dictionary<string, string>(view.TextFields); FileFields = new Dictionary<string, string>(view.FileFields); } private void EditProfile_Load(object sender, EventArgs e) { RefreshTemplates(); } private void RefreshTemplates() { Templates.Clear(); // list chain of command first List<ulong> highers = Links.GetUplinkIDs(Core.UserID, 0); highers.Reverse(); highers.Add(Links.LocalTrust.UserID); // list higher level users, indent also // dont repeat names using same template+ int space = 0; foreach (ulong id in highers) { ProfileTemplate add = GetTemplate(id); if (add == null || add.Hash == null) continue; foreach(ProfileTemplate template in TemplateCombo.Items) if (Utilities.MemCompare(add.Hash, template.Hash)) continue; for (int i = 0; i < space; i++) add.User = " " + add.User; TemplateCombo.Items.Add(add); space += 4; } // sort rest alphabetically List<ProfileTemplate> templates = new List<ProfileTemplate>(); // read profile header file Profiles.ProfileMap.LockReading(delegate() { foreach (ulong id in Profiles.ProfileMap.Keys) { ProfileTemplate add = GetTemplate(id); if (add == null || add.Hash == null) continue; bool dupe = false; foreach (ProfileTemplate template in TemplateCombo.Items) if (Utilities.MemCompare(add.Hash, template.Hash)) dupe = true; foreach (ProfileTemplate template in templates) if (Utilities.MemCompare(add.Hash, template.Hash)) dupe = true; if (!dupe) templates.Add(add); } }); // add space between chain items and other items if (TemplateCombo.Items.Count > 0 && templates.Count > 0) TemplateCombo.Items.Add(new ProfileTemplate(true, false)); templates.Sort(); foreach (ProfileTemplate template in templates) TemplateCombo.Items.Add(template); // select local template ProfileTemplate local = GetTemplate(Core.UserID); if(local != null) foreach (ProfileTemplate template in TemplateCombo.Items) if (Utilities.MemCompare(local.Hash, template.Hash)) { TemplateCombo.SelectedItem = template; break; } } private ProfileTemplate GetTemplate(ulong id) { OpProfile profile = Profiles.GetProfile(id); if (profile == null) return null; ProfileTemplate template = new ProfileTemplate(false, true); template.User = Core.GetName(id); ; template.FilePath = Profiles.GetFilePath(profile); template.FileKey = profile.File.Header.FileKey; if (!profile.Loaded) Profiles.LoadProfile(profile.UserID); try { using (TaggedStream stream = new TaggedStream(template.FilePath, Core.GuiProtocol)) using (IVCryptoStream crypto = IVCryptoStream.Load(stream, template.FileKey)) { int buffSize = 4096; byte[] buffer = new byte[4096]; long bytesLeft = profile.EmbeddedStart; while (bytesLeft > 0) { int readSize = (bytesLeft > (long)buffSize) ? buffSize : (int)bytesLeft; int read = crypto.Read(buffer, 0, readSize); bytesLeft -= (long)read; } foreach (ProfileAttachment attach in profile.Attached) if (attach.Name.StartsWith("template")) { byte[] html = new byte[attach.Size]; crypto.Read(html, 0, (int)attach.Size); template.Html = UTF8Encoding.UTF8.GetString(html); SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider(); template.Hash = sha1.ComputeHash(html); break; } } } catch { return null; } return template; } int NewCount = 0; private void LinkNew_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { ProfileTemplate newTemplate = new ProfileTemplate(false, false); newTemplate.User = "New"; newTemplate.Html = ""; if (NewCount > 0) newTemplate.User += " " + NewCount.ToString(); NewCount++; EditTemplate edit = new EditTemplate(newTemplate, this); edit.ShowDialog(this); } private void LinkEdit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (TemplateCombo.SelectedItem == null) return; ProfileTemplate template = (ProfileTemplate)TemplateCombo.SelectedItem; if (template.Inactive) return; // if ondisk, copy before editing if (template.OnDisk) { ProfileTemplate copy = new ProfileTemplate(false, false); copy.User = template.User + " (edited)"; copy.User = copy.User.TrimStart(new char[] { ' ' }); copy.Html = template.Html; template = copy; } EditTemplate edit = new EditTemplate(template, this); edit.ShowDialog(this); } private void LinkPreview_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (TemplateCombo.SelectedItem == null) return; ProfileTemplate template = (ProfileTemplate) TemplateCombo.SelectedItem; if (template.Inactive) return; PreviewTemplate preview = new PreviewTemplate(template.Html, this); preview.ShowDialog(this); } public void TemplateCombo_SelectedIndexChanged(object sender, EventArgs e) { FieldsCombo.Items.Clear(); ValueTextBox.Text = ""; if (TemplateCombo.SelectedItem == null) return; ProfileTemplate template = (ProfileTemplate)TemplateCombo.SelectedItem; if (template.Inactive) return; List<TemplateTag> tags = new List<TemplateTag>(); // extract tag names from html string html = template.Html; // replace fields while (html.Contains("<?")) { int start = html.IndexOf("<?"); int end = html.IndexOf("?>"); if (end == -1) break; string fulltag = html.Substring(start, end + 2 - start); string tag = fulltag.Substring(2, fulltag.Length - 4); string[] parts = tag.Split(new char[] { ':' }); if (parts.Length == 2) { if (parts[0] == "text") tags.Add(new TemplateTag(parts[1], ProfileFieldType.Text)); else if (parts[0] == "file") tags.Add(new TemplateTag(parts[1], ProfileFieldType.File)); } html = html.Replace(fulltag, ""); } tags.Sort(); bool motdAdded = false; // add just 1 to change foreach (TemplateTag tag in tags) { // if motd for this project, allow if (tag.Name.StartsWith("MOTD")) if (!motdAdded) { tag.Name = "MOTD"; motdAdded = true; } else continue; FieldsCombo.Items.Add(tag); } if (FieldsCombo.Items.Count > 0) { FieldsCombo.SelectedItem = FieldsCombo.Items[0]; FieldsCombo_SelectedIndexChanged(null, null); } } private void FieldsCombo_SelectedIndexChanged(object sender, EventArgs e) { if (FieldsCombo.SelectedItem == null) return; TemplateTag tag = (TemplateTag)FieldsCombo.SelectedItem; if (tag.FieldType == ProfileFieldType.Text) { LinkBrowse.Enabled = false; ValueTextBox.ReadOnly = false; } else { LinkBrowse.Enabled = true; ValueTextBox.ReadOnly = true; } // set value text if (tag.FieldType == ProfileFieldType.Text) { string fieldName = tag.Name; if (fieldName == "MOTD") fieldName = "MOTD-" + MainView.GetProjectID().ToString(); if (TextFields.ContainsKey(fieldName)) ValueTextBox.Text = TextFields[fieldName]; else ValueTextBox.Text = ""; } else if (tag.FieldType == ProfileFieldType.File && FileFields.ContainsKey(tag.Name)) ValueTextBox.Text = FileFields[tag.Name]; else ValueTextBox.Text = "Click Browse to select a file"; ValueTextBox_TextChanged(null, null); } private void ValueTextBox_TextChanged(object sender, EventArgs e) { if (FieldsCombo.SelectedItem == null) return; TemplateTag tag = (TemplateTag) FieldsCombo.SelectedItem; if (tag.FieldType == ProfileFieldType.Text) { string fieldName = tag.Name; if (fieldName == "MOTD") fieldName = "MOTD-" + MainView.GetProjectID().ToString(); TextFields[fieldName] = ValueTextBox.Text; } if (tag.FieldType == ProfileFieldType.File) FileFields[tag.Name] = ValueTextBox.Text; } private void LinkBrowse_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (FieldsCombo.SelectedItem == null) return; TemplateTag tag = (TemplateTag)FieldsCombo.SelectedItem; OpenFileDialog open = new OpenFileDialog(); open.Multiselect = true; open.Title = "Browse for File"; open.Filter = "All files (*.*)|*.*"; if (open.ShowDialog() == DialogResult.OK) { ValueTextBox.Text = open.FileName; FileFields[tag.Name] = open.FileName; } } private void ButtonOK_Click(object sender, EventArgs e) { if (TemplateCombo.SelectedItem == null) { Close(); return; } ProfileTemplate template = (ProfileTemplate)TemplateCombo.SelectedItem; if (template.Inactive) { Close(); return; } // remove text fields that are not in template List<string> removeKeys = new List<string>(); foreach (string key in TextFields.Keys) if (!key.StartsWith("MOTD") && !template.Html.Contains("<?text:" + key)) removeKeys.Add(key); foreach (string key in removeKeys) TextFields.Remove(key); // remove files that are not in template removeKeys.Clear(); foreach (string key in FileFields.Keys) if (!template.Html.Contains("<?file:" + key)) removeKeys.Add(key); foreach (string key in removeKeys) FileFields.Remove(key); // save profile will also update underlying interface Profiles.SaveLocal(template.Html, TextFields, FileFields); Close(); } private void ButtonCancel_Click(object sender, EventArgs e) { Close(); } } public class ProfileTemplate : IComparable { public bool Inactive; public bool OnDisk; public string User = ""; public string FilePath; public byte[] FileKey; public string Html = ""; public byte[] Hash; public ProfileTemplate(bool inactive, bool ondisk) { Inactive = inactive; OnDisk = ondisk; } public override string ToString() { return User; } public int CompareTo(object obj) { return User.CompareTo(((ProfileTemplate)obj).User); } } public class TemplateTag : IComparable { public string Name ; public ProfileFieldType FieldType; public TemplateTag(string name, ProfileFieldType type) { Name = name; FieldType = type; } public override string ToString() { return Name; } public int CompareTo(object obj) { return Name.CompareTo(((TemplateTag)obj).Name); } } }
swax/DeOps
UI/Services/Profile/EditProfile.cs
C#
bsd-2-clause
15,097
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import django_google_dork.models import model_utils.fields import django.utils.timezone class Migration(migrations.Migration): replaces = [('django_google_dork', '0001_initial'), ('django_google_dork', '0002_auto_20141116_1551'), ('django_google_dork', '0003_run_engine')] dependencies = [ ] operations = [ migrations.CreateModel( name='Campaign', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)), ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)), ('name', django_google_dork.models.CampaignNameField(unique=True, max_length=32)), ], options={ 'abstract': False, }, bases=(models.Model,), ), migrations.CreateModel( name='Dork', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)), ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)), ('query', django_google_dork.models.DorkQueryField(max_length=256)), ('campaign', models.ForeignKey(to='django_google_dork.Campaign')), ], options={ }, bases=(models.Model,), ), migrations.CreateModel( name='Result', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=1024)), ('summary', models.TextField()), ('url', models.URLField(max_length=1024)), ], options={ }, bases=(models.Model,), ), migrations.CreateModel( name='Run', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', models.DateTimeField(auto_now_add=True)), ('dork', models.ForeignKey(to='django_google_dork.Dork')), ('result_set', models.ManyToManyField(to='django_google_dork.Result')), ], options={ }, bases=(models.Model,), ), migrations.AlterUniqueTogether( name='result', unique_together=set([('title', 'summary', 'url')]), ), migrations.AlterUniqueTogether( name='dork', unique_together=set([('campaign', 'query')]), ), migrations.CreateModel( name='SearchEngine', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('hostname', models.CharField(unique=True, max_length=32)), ], options={ }, bases=(models.Model,), ), migrations.AddField( model_name='campaign', name='enabled', field=models.BooleanField(default=True), preserve_default=True, ), migrations.AddField( model_name='dork', name='enabled', field=models.BooleanField(default=True), preserve_default=True, ), migrations.AddField( model_name='run', name='engine', field=models.ForeignKey(default=None, to='django_google_dork.SearchEngine'), preserve_default=False, ), ]
chgans/django-google-dork
django_google_dork/migrations/0001_initial.py
Python
bsd-2-clause
4,143
//------------------------------------------------------------------------------ // Symbooglix // // // Copyright 2014-2017 Daniel Liew // // This file is licensed under the MIT license. // See LICENSE.txt for details. //------------------------------------------------------------------------------ using Microsoft.Boogie; using NUnit.Framework; using SymbooglixLibTests; // FIXME: We shouldn't depend on this. using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; namespace BoogieTests { public class BoogieTest { public static void setupDebug() { // Debug log output goes to standard error. // Failing System.Diagnostics failures trigger NUnit assertion failures Debug.Listeners.Add(new AssertionTextWriterTraceListener(Console.Error)); } public static void setupCmdLineParser() { // THIS IS A HACK. Boogie's methods // depend on its command line parser being set! CommandLineOptions.Install(new Microsoft.Boogie.CommandLineOptions()); } public static Program loadProgram(String path) { setupDebug(); Assert.IsTrue(File.Exists(path)); setupCmdLineParser(); int errors = 0; Program p = null; List<String> defines = null; errors = Parser.Parse(path, defines, out p); Assert.AreEqual(0, errors); Assert.IsNotNull(p); // Resolve errors = p.Resolve(); Assert.AreEqual(0, errors); // Type check errors = p.Typecheck(); Assert.AreEqual(0, errors); return p; } } }
symbooglix/symbooglix
src/BoogieTests/BoogieTest.cs
C#
bsd-2-clause
1,787
// Copyright (c) 2022, WNProject Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "WNMultiTasking/inc/thread.h" #include "WNMemory/inc/allocator.h" #include "WNMemory/inc/intrusive_ptr.h" #include "WNMultiTasking/inc/semaphore.h" #include "core/inc/assert.h" #include "core/inc/utilities.h" namespace wn { namespace multi_tasking { const thread::attributes thread::default_attributes = { 0, // stack size false // low priority }; void thread::create(memory::allocator* _allocator, const attributes& _attributes, functional::function<void()>&& _f) { memory::intrusive_ptr<private_data> data( memory::make_intrusive<private_data>(_allocator, _allocator)); if (data) { semaphore start_lock; private_execution_data* execution_data = _allocator->construct<private_execution_data>( _allocator, &start_lock, core::move(_f), data); if (execution_data) { const bool creation_success = base::create(_attributes, data.get(), execution_data); if (creation_success) { m_data = core::move(data); start_lock.wait(); } else { _allocator->destroy(execution_data); WN_RELEASE_ASSERT(creation_success, "failed to create thread"); } } else { WN_RELEASE_ASSERT(execution_data, "failed to allocate needed execution data for thread"); } } else { WN_RELEASE_ASSERT(data, "failed to allocate needed data for thread"); } } } // namespace multi_tasking } // namespace wn
WNProject/WNFramework
Libraries/WNMultiTasking/src/thread.cpp
C++
bsd-2-clause
1,608
function Get-LaunchSettings(){ ls -Recurse -Filter launchSettings.json|%{ $fileName = $_.Directory.Parent; gc $_.FullName|ConvertFrom-Json|%{ $url=$_.profiles."$fileName".applicationUrl; Write-Host "$fileName : $url"; } } }
iamkarlson/dotfiles
powershell/autorun/get-launchsettings.ps1
PowerShell
bsd-2-clause
273
/* * Copyright (c) 2013 Ambroz Bizjak * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * * 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 AUTHOR 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 AMBROLIB_DELTA_TRANSFORM_H #define AMBROLIB_DELTA_TRANSFORM_H #include <stdint.h> #include <aprinter/meta/BasicMetaUtils.h> #include <aprinter/meta/ServiceUtils.h> #include <aprinter/base/Object.h> #include <aprinter/math/Vector3.h> #include <aprinter/math/FloatTools.h> #include <aprinter/printer/Configuration.h> namespace APrinter { template <typename Arg> class DeltaTransform { using Context = typename Arg::Context; using ParentObject = typename Arg::ParentObject; using Config = typename Arg::Config; using FpType = typename Arg::FpType; using Params = typename Arg::Params; private: using MyVector = Vector3<FpType>; public: static int const NumAxes = 3; template <typename Src, typename Dst> static bool virtToPhys (Context c, Src virt, Dst out_phys) { FpType x = virt.template get<0>(); FpType y = virt.template get<1>(); FpType z = virt.template get<2>(); if (!(x*x + y*y <= APRINTER_CFG(Config, CLimitRadius2, c))) { return false; } out_phys.template set<0>(FloatSqrt(APRINTER_CFG(Config, CDiagonalRod1_2, c) - FloatSquare(APRINTER_CFG(Config, CTower1X, c) - x) - FloatSquare(APRINTER_CFG(Config, CTower1Y, c) - y)) + z); out_phys.template set<1>(FloatSqrt(APRINTER_CFG(Config, CDiagonalRod2_2, c) - FloatSquare(APRINTER_CFG(Config, CTower2X, c) - x) - FloatSquare(APRINTER_CFG(Config, CTower2Y, c) - y)) + z); out_phys.template set<2>(FloatSqrt(APRINTER_CFG(Config, CDiagonalRod3_2, c) - FloatSquare(APRINTER_CFG(Config, CTower3X, c) - x) - FloatSquare(APRINTER_CFG(Config, CTower3Y, c) - y)) + z); return true; } template <typename Src, typename Dst> static void physToVirt (Context c, Src phys, Dst out_virt) { MyVector p1 = MyVector::make(APRINTER_CFG(Config, CTower1X, c), APRINTER_CFG(Config, CTower1Y, c), phys.template get<0>()); MyVector p2 = MyVector::make(APRINTER_CFG(Config, CTower2X, c), APRINTER_CFG(Config, CTower2Y, c), phys.template get<1>()); MyVector p3 = MyVector::make(APRINTER_CFG(Config, CTower3X, c), APRINTER_CFG(Config, CTower3Y, c), phys.template get<2>()); // We need to find the point p which is exactly (r1, r2, r3) away from the points // (p1, p2, p3) respectively, where ri are the diagonal rod lengths. This code // is based on the solution on Wikipedia: // https://en.wikipedia.org/wiki/True_range_multilateration#Three_Cartesian_dimensions,_three_measured_slant_ranges // // The idea is to work in a local (X, Y, Z) coordinate system defined by p1, p2, p3 // such that: // - p1 is at (0, 0, 0), // - p2 is at (u, 0, 0), // - p3 is at (vx, vy, 0), // - p (the solution) is at (x, y, z). // Calculate u as the length of the vector p2 - p1. MyVector d12 = p2 - p1; FpType u_2 = d12.squaredLength(); FpType u = FloatSqrt(u_2); // Calculate ex, the unit vector in the direction of p2 - p1. MyVector ex = d12 / u; // Calculate vx by projecting the vector p3 - p1 to ex (note that ex is a unit // vector so there is no need to normalize after the dot product). MyVector d13 = p3 - p1; FpType vx = d13.dot(ex); // Calculate vy_v, the rejection of p3 - p1 after projection to ex. MyVector vy_v = d13 - ex * vx; // Calculate vy as the length of vy_v. FpType vy = vy_v.length(); // Calculate ey, the unit vector in the direction of the Y axis. MyVector ey = vy_v / vy; // Get the squares of ri into variables. FpType r1_2 = APRINTER_CFG(Config, CDiagonalRod1_2, c); FpType r2_2 = APRINTER_CFG(Config, CDiagonalRod2_2, c); FpType r3_2 = APRINTER_CFG(Config, CDiagonalRod3_2, c); // Calculate v_2. This is equal to the squared length of p3 - p1, but it // is more efficient to calculate it from vx and vy. FpType v_2 = vx * vx + vy * vy; // Calculate (x, y, z) using the formulas. Note that we need the negative z // because we are interested in solution below (p1, p2, p3), not the one above. FpType x = (r1_2 - r2_2 + u_2) / (2.0f * u); FpType y = (r1_2 - r3_2 + v_2 - 2.0f * vx * x) / (2.0f * vy); FpType z = -FloatSqrt(r1_2 - x * x - y * y); // Calculate ez, the unit vector in the direction of the Z axis. MyVector ez = ex.cross(ey); // Calculate the result p by transforming (x, y, z) into the global coordinate // system. MyVector p = p1 + ex * x + ey * y + ez * z; out_virt.template set<0>(p.m_v[0]); out_virt.template set<1>(p.m_v[1]); out_virt.template set<2>(p.m_v[2]); } private: using DiagonalRod = decltype(Config::e(Params::DiagonalRod::i())); using DiagonalRodCorr1 = decltype(Config::e(Params::DiagonalRodCorr1::i())); using DiagonalRodCorr2 = decltype(Config::e(Params::DiagonalRodCorr2::i())); using DiagonalRodCorr3 = decltype(Config::e(Params::DiagonalRodCorr3::i())); using Radius = decltype(Config::e(Params::SmoothRodOffset::i()) - Config::e(Params::EffectorOffset::i()) - Config::e(Params::CarriageOffset::i())); using LimitRadius = decltype(Config::e(Params::LimitRadius::i())); using Value1 = APRINTER_FP_CONST_EXPR(-0.8660254037844386); using Value2 = APRINTER_FP_CONST_EXPR(-0.5); using Value3 = APRINTER_FP_CONST_EXPR(0.8660254037844386); using Value4 = APRINTER_FP_CONST_EXPR(0.0); using Value5 = APRINTER_FP_CONST_EXPR(1.0); using CDiagonalRod1_2 = decltype(ExprCast<FpType>(ExprSquare(DiagonalRod() + DiagonalRodCorr1()))); using CDiagonalRod2_2 = decltype(ExprCast<FpType>(ExprSquare(DiagonalRod() + DiagonalRodCorr2()))); using CDiagonalRod3_2 = decltype(ExprCast<FpType>(ExprSquare(DiagonalRod() + DiagonalRodCorr3()))); using CTower1X = decltype(ExprCast<FpType>(Radius() * Value1())); using CTower1Y = decltype(ExprCast<FpType>(Radius() * Value2())); using CTower2X = decltype(ExprCast<FpType>(Radius() * Value3())); using CTower2Y = decltype(ExprCast<FpType>(Radius() * Value2())); using CTower3X = decltype(ExprCast<FpType>(Radius() * Value4())); using CTower3Y = decltype(ExprCast<FpType>(Radius() * Value5())); using CLimitRadius2 = decltype(ExprCast<FpType>(LimitRadius() * LimitRadius())); public: using ConfigExprs = MakeTypeList<CDiagonalRod1_2, CDiagonalRod2_2, CDiagonalRod3_2, CTower1X, CTower1Y, CTower2X, CTower2Y, CTower3X, CTower3Y, CLimitRadius2>; struct Object : public ObjBase<DeltaTransform, ParentObject, EmptyTypeList> {}; }; APRINTER_ALIAS_STRUCT_EXT(DeltaTransformService, ( APRINTER_AS_TYPE(DiagonalRod), APRINTER_AS_TYPE(DiagonalRodCorr1), APRINTER_AS_TYPE(DiagonalRodCorr2), APRINTER_AS_TYPE(DiagonalRodCorr3), APRINTER_AS_TYPE(SmoothRodOffset), APRINTER_AS_TYPE(EffectorOffset), APRINTER_AS_TYPE(CarriageOffset), APRINTER_AS_TYPE(LimitRadius) ), ( APRINTER_ALIAS_STRUCT_EXT(Transform, ( APRINTER_AS_TYPE(Context), APRINTER_AS_TYPE(ParentObject), APRINTER_AS_TYPE(Config), APRINTER_AS_TYPE(FpType) ), ( using Params = DeltaTransformService; APRINTER_DEF_INSTANCE(Transform, DeltaTransform) )) )) } #endif
ambrop72/aprinter
aprinter/printer/transform/DeltaTransform.h
C
bsd-2-clause
8,806
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__) class Php53Raphf < AbstractPhp53Extension init desc "A reusable split-off of pecl_http's persistent handle and resource factory API." homepage "https://pecl.php.net/package/raphf" url "https://pecl.php.net/get/raphf-1.0.4.tgz" sha256 "461be283e89d94186a3ed4651b92c7c1a067bad7b6476d0ca7ac8863dc1ed8bf" bottle do sha256 "d85407c95983c971a3d739e723379ce76f15e1079ef29dae87154da025451284" => :yosemite sha256 "6f5e4fac12bb82faa93896c815ceb14305d64096ef57229ec151eb71b2f019ed" => :mavericks sha256 "083d883ccc79f29b185bb4e73f4560f8bde0fc20f0cfa9ad3479779f3db289c4" => :mountain_lion end def install Dir.chdir "raphf-#{version}" ENV.universal_binary if build.universal? safe_phpize system "./configure", "--prefix=#{prefix}", phpconfig system "make" include.install "php_raphf.h" prefix.install "modules/raphf.so" write_config_file if build.with? "config-file" end end
TomK/homebrew-php
Formula/php53-raphf.rb
Ruby
bsd-2-clause
1,032
/* Copyright (c) Citrix Systems Inc. * All rights reserved. * * 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. * * 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. */ /* * Based upon code copyrighted as below. */ // // Copyright (c) 2008-2010, Kenneth Bell // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Generic; using System.IO; using DiscUtils; using DiscUtils.Iscsi; namespace XenOvfTransport { // iSCSI disk stream to workaround a bug in DiscUtils.DiskStream. public class DiskStream : SparseStream { private Session _session; private long _lun; private long _length; private long _position; private int _blockSize; private bool _canWrite; private bool _canRead; public DiskStream(Session session, long lun, FileAccess access) { _session = session; _lun = lun; LunCapacity capacity = session.GetCapacity(lun); _blockSize = capacity.BlockSize; //////////////////////////////////////////////////////////////////////////////////////////////////// // CORRECTION // SCSI Read Capacity response includes the *last* logical block address (LBA) and NOT // the logical block count as interpreted by DiscUtils.DiskStream. // Account for the last block. _length = (capacity.LogicalBlockCount + 1) * capacity.BlockSize; //////////////////////////////////////////////////////////////////////////////////////////////////// _canWrite = (access != FileAccess.Read); _canRead = (access != FileAccess.Write); } public override bool CanRead { get { return _canRead; } } public override bool CanSeek { get { return true; } } public override bool CanWrite { get { return _canWrite; } } public override void Flush() { } public override long Length { get { return _length; } } public override long Position { get { return _position; } set { _position = value; } } public override int Read(byte[] buffer, int offset, int count) { if (!CanRead) { throw new InvalidOperationException("Attempt to read from read-only stream"); } int maxToRead = (int)Math.Min(_length - _position, count); long firstBlock = _position / _blockSize; //////////////////////////////////////////////////////////////////////////////////////////////////// // CORRECTION // DiscUtils.Utilities is not accessible. // long lastBlock = Utilities.Ceil(_position + maxToRead, _blockSize); long lastBlock = ((_position + maxToRead) + (_blockSize - 1)) / _blockSize; //////////////////////////////////////////////////////////////////////////////////////////////////// byte[] tempBuffer = new byte[(lastBlock - firstBlock) * _blockSize]; int numRead = _session.Read(_lun, firstBlock, (short)(lastBlock - firstBlock), tempBuffer, 0); int numCopied = Math.Min(maxToRead, numRead); Array.Copy(tempBuffer, _position - (firstBlock * _blockSize), buffer, offset, numCopied); _position += numCopied; return numCopied; } public override long Seek(long offset, SeekOrigin origin) { long effectiveOffset = offset; if (origin == SeekOrigin.Current) { effectiveOffset += _position; } else if (origin == SeekOrigin.End) { effectiveOffset += _length; } if (effectiveOffset < 0) { throw new IOException("Attempt to move before beginning of disk"); } else { _position = effectiveOffset; return _position; } } public override void SetLength(long value) { throw new NotSupportedException(); } public override void Write(byte[] buffer, int offset, int count) { if (!CanWrite) { throw new IOException("Attempt to write to read-only stream"); } if (_position + count > _length) { throw new IOException("Attempt to write beyond end of stream"); } int numWritten = 0; while (numWritten < count) { long block = _position / _blockSize; uint offsetInBlock = (uint)(_position % _blockSize); int toWrite = count - numWritten; // Need to read - we're not handling a full block if (offsetInBlock != 0 || toWrite < _blockSize) { toWrite = (int)Math.Min(toWrite, _blockSize - offsetInBlock); byte[] blockBuffer = new byte[_blockSize]; int numRead = _session.Read(_lun, block, 1, blockBuffer, 0); if (numRead != _blockSize) { throw new IOException("Incomplete read, received " + numRead + " bytes from 1 block"); } // Overlay as much data as we have for this block Array.Copy(buffer, offset + numWritten, blockBuffer, offsetInBlock, toWrite); // Write the block back _session.Write(_lun, block, 1, _blockSize, blockBuffer, 0); } else { // Processing at least one whole block, just write (after making sure to trim any partial sectors from the end)... short numBlocks = (short)(toWrite / _blockSize); toWrite = numBlocks * _blockSize; _session.Write(_lun, block, numBlocks, _blockSize, buffer, offset + numWritten); } numWritten += toWrite; _position += toWrite; } } public override IEnumerable<StreamExtent> Extents { get { yield return new StreamExtent(0, _length); } } } }
aftabahmedsajid/XenCenter-Complete-dependencies-
XenOvfTransport/DiskStream.cs
C#
bsd-2-clause
8,868
class Procs < Formula desc "Modern replacement for ps written by Rust" homepage "https://github.com/dalance/procs" url "https://github.com/dalance/procs/archive/v0.10.3.tar.gz" sha256 "cbb31a3a94b0c697aeb687f103c9128b3fed006cd0c802fb47f5c67415c32181" license "MIT" bottle do cellar :any_skip_relocation sha256 "e4d64cc107a0b3c5a897655778eb3a1b10a30e2ed065c57c8f7e566ad75eccfb" => :catalina sha256 "4885c058e98ae2a7a7bca686fb6ba1b9a14e760b4bcf4bd4aace931088b382a8" => :mojave sha256 "88010001010a5d2b4e30a5e3adf5ba4e75e72d4ccb7bf8da78c326e09e928d4f" => :high_sierra end depends_on "rust" => :build def install system "cargo", "install", *std_cargo_args end test do output = shell_output("#{bin}/procs") count = output.lines.count assert count > 2 assert output.start_with?(" PID:") end end
lembacon/homebrew-core
Formula/procs.rb
Ruby
bsd-2-clause
853
namespace CustomActions.Utils { using System; using bv.common.Core; using Microsoft.Deployment.WindowsInstaller; public static class CultureRegistrator { public static void TryRegisterCustomCultures(Session session) { try { CustomCultureHelper.UnRegisterAll(); CustomCultureHelper.RegisterAll(); } catch (Exception ex) { session.Log(string.IsNullOrEmpty(ex.InnerException.Message) ? ex.Message : ex.InnerException.Message); } } } }
EIDSS/EIDSS-Legacy
EIDSS v6.1/EIDSS.Setup/CustomActions.Utils/CultureRegistrator.cs
C#
bsd-2-clause
542
# RIPACrypt This is the client side application for [RIPACrypt](https://ripacrypt.download) which remotely stores secrets which are destroyed if a deadline is reached without a checkin (a form a deadman switch). This is another thought experiment in defeating the Regulation of Investigatory Powers Act 2000 Section 49 (compelled decryption) legislation using technology. ## Process We do not provide prebuilt binaries so that you can ensure that the code you are running is doing what we say it is. 1. Prepare your [GoLang work directory](https://golang.org/doc/code.html#Workspaces) 2. Issue `go get github.com/BrassHornCommunications/RIPACrypt` 3. Issue `cd src/github.com/BrassHornCommunications/RIPACrypt` 4. Issue `go build -o rcrypt && sudo cp rcrypt /usr/local/bin/` 5. Follow instructions below ## Using RIPACrypt The simplest way to use RIPACrypt is to register a new account _(allowing the client to generate a new GPG key pair)_ and then piping in the content you want to encrypt and store _(accepting the 3 day expiry default)_ Please note that you do not have to use this client, the API is very easy to use _(to the point you can just use `bash`, `curl`, `gpg` and `base64`. See [ExampleCurlCalls](https://github.com/BrassHornCommunications/RIPACryptd/blob/master/ExampleCurlCalls.md) for more details.)_ ### Registering ```rcrypt register``` This will create `~/ripacrypt/rc.conf` which will contain your user ID, your unique bitcoin address and your GPG key pair. ### Encrypt and Store Some Data _(with a 3 day expiry)_ ```echo "MySuperStrongPassphrase" | rcrypt new -description="Something that obscurely links this crypt with the protected data"``` RIPACrypt will encrypt the data you passed with the public keypair generated earlier _(Note: This encryption can be considered 'end-to-end' as we never have access to your private key)_ and then submits it to the server. You will need to checkin at least every 3 days _(72 hours)_ or your crypt will be destroyed _(but preferably every 24 hours)_. ### Checkin with your crypt ```rcrypt checkin -crypt=CRYPTHASH``` Checking in with a crypt will 'reset' the self destruction countdown. Failing to checkin within the configured limit _(default of 3x 24 hours)_ will result in a crypt being destroyed. ### My Computer has been seized and I've been served a RIPA s.49 Notice Assuming the RIPA s.49 notice has been issued _after_ the crypts self destruction deadline simply provide your Crypt ID and explain RIPA Crypt _(See Disclaimers below!!!)_ ## Advanced Usage ### `[register new checkin getchallenge newbtc]` -usetor Attempts to connect to the RIPACrypt service via the SOCKS5 proxy exposed by Tor ### `[register new checkin getchallenge newbtc]` -debug Will print the full JSON reply from the API for any query ### `new` -description="x" Provides a description of the crypt that can help prove that this destroyed crypt held the passphrase for your disks. Examples could be the serial number of the storage media in question. ### `new` -checkincount=x -misscount=y Choose different checkin _(in seconds)_ and miss counts. E.g. you could specify 30 minutes _(1800 seconds)_ with a miss count of 5, providing a total of 2 and half hours before self destruction. The reason for having two variables is that in future versions we might enable notifications for each missed duration. ## Development - [x] Register - [x] Create a new crypt - [x] Checkin with crypt - [x] Get a challenge - [x] Get a new Bitcoin address - [ ] Delete a crypt - [ ] Specify a notification method if a checkin period is missed ## Pull Requests And Development Whilst this is a working SaaS product the main purpose of the project is to get people thinking about the perils of laws that can compel decryption. With that said we would appreciate any pull requests / issues / suggestions / help. ## Disclaimers **We are not a lawyers, solictiors or in any way well versed in the law. This software may result in you being found guilty of Failure to comply with a notice under the Regulation of Investigatory Powers Act 2000 and sentenced to up to 5 years in prison (or worse)** > 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.
BrassHornCommunications/RIPACrypt
README.md
Markdown
bsd-2-clause
4,901
/** Copyright 2015 Couchbase, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. **/ var StatsModel = {}; (function (self) { // starts future.get with given ajaxOptions and arranges invocation // of 'body' with value or if future is cancelled invocation of body // with 'cancelledValue'. // // NOTE: this is not normal future as normal futures deliver values // to cell, but this one 'delivers' values to given function 'body'. function getCPS(ajaxOptions, cancelledValue, body) { // this wrapper calls 'body' instead of delivering value to it's // cell var futureWrapper = future.wrap(function (ignoredDataCallback, startGet) { return startGet(body); }); var async = future.get(ajaxOptions, undefined, undefined, futureWrapper); async.cancel = (function (realCancel) { return function () { if (realCancel) { realCancel.call(this); } body(cancelledValue); } })(async.cancel); // we need any cell here to satisfy our not yet perfect API async.start(new Cell()); return async; } function createSamplesFuture(opts, bufferDepth) { var cancelMark = {}; var mark404 = {}; function doGet(data, body) { if (mainAsync.cancelled) { return body(cancelMark); } function onCancel() { if (async) { async.cancel(); } } function unbind() { $(mainAsync).unbind('cancelled', onCancel); } $(mainAsync).bind('cancelled', onCancel); var async; return async = getCPS({url: '/_uistats', data: data, missingValue: mark404}, cancelMark, function (value, status, xhr) { unbind(); if (value !== cancelMark && value !== mark404) { var date = xhr.getResponseHeader('date'); value.serverDate = parseHTTPDate(date).valueOf(); value.clientDate = (new Date()).valueOf(); } body(value, status, xhr); }); } var dataCallback; var mainAsync = future(function (_dataCallback) { dataCallback = _dataCallback; loop(); }); mainAsync.cancel = function () { $(this).trigger("cancelled"); }; var extraOpts = {}; var prevValue; return mainAsync; function loop(deliverValue) { doGet(_.extend({}, opts, extraOpts), onLoopData); } function onLoopData(value) { if (value === mark404) { return; } if (prevValue) { value = maybeApplyDelta(prevValue, value); } if (!dataCallback.continuing(value)) { return; } prevValue = value; if (value.lastTStamp) { extraOpts = {haveTStamp: JSON.stringify(value.lastTStamp)}; } if (!('nextReqAfter' in value)) { BUG(); } setTimeout(loop, value.nextReqAfter); } function restoreOpsBlock(prevSamples, samples, keepCount) { var prevTS = prevSamples.timestamp; if (samples.timestamp && samples.timestamp.length == 0) { // server was unable to return any data for this "kind" of // stats if (prevSamples && prevSamples.timestamp && prevSamples.timestamp.length > 0) { return prevSamples; } return samples; } if (prevTS == undefined || prevTS.length == 0 || prevTS[prevTS.length-1] != samples.timestamp[0]) { return samples; } var newSamples = {}; for (var keyName in samples) { var ps = prevSamples[keyName]; if (!ps) { ps = []; ps.length = keepCount; } newSamples[keyName] = ps.concat(samples[keyName].slice(1)).slice(-keepCount); } return newSamples; } function maybeApplyDelta(prevValue, value) { var stats = value.stats; var prevStats = prevValue.stats || {}; for (var kind in stats) { var newSamples = restoreOpsBlock(prevStats[kind], stats[kind], value.samplesCount + bufferDepth); stats[kind] = newSamples; } return value; } } var statsBucketURL = self.statsBucketURL = new StringHashFragmentCell("statsBucket"); var statsHostname = self.statsHostname = new StringHashFragmentCell("statsHostname"); var statsStatName = self.statsStatName = new StringHashFragmentCell("statsStatName"); self.selectedGraphNameCell = new StringHashFragmentCell("graph"); self.configurationExtra = new Cell(); self.smallGraphSelectionCellCell = Cell.compute(function (v) { return v.need(self.displayingSpecificStatsCell) ? self.statsHostname : self.selectedGraphNameCell; }); // contains bucket details of statsBucketURL bucket (or default if there are no such bucket) var statsBucketDetails = self.statsBucketDetails = Cell.compute(function (v) { var uri = v(statsBucketURL); var buckets = v.need(DAL.cells.bucketsListCell); var rv; if (uri !== undefined) { rv = _.detect(buckets, function (info) {return info.uri === uri}); } else { rv = _.detect(buckets, function (info) {return info.name === "default"}) || buckets[0]; } return rv; }).name("statsBucketDetails"); var statsOptionsCell = self.statsOptionsCell = (new Cell()).name("statsOptionsCell"); statsOptionsCell.setValue({}); _.extend(statsOptionsCell, { update: function (options) { this.modifyValue(_.bind($.extend, $, {}), options); }, equality: _.isEqual }); var samplesBufferDepthRAW = new StringHashFragmentCell("statsBufferDepth"); self.samplesBufferDepth = Cell.computeEager(function (v) { return v(samplesBufferDepthRAW) || 1; }); var zoomLevel; (function () { var slider = $("#js_date_slider").slider({ orientation: "vertical", range: "min", min: 1, max: 6, value: 6, step: 1, slide: function(event, ui) { var dateSwitchers = $("#js_date_slider_container .js_click"); dateSwitchers.eq(dateSwitchers.length - ui.value).trigger('click'); } }); zoomLevel = (new LinkSwitchCell('zoom', { firstItemIsDefault: true })).name("zoomLevel"); _.each('minute hour day week month year'.split(' '), function (name) { zoomLevel.addItem('js_zoom_' + name, name); }); zoomLevel.finalizeBuilding(); zoomLevel.subscribeValue(function (zoomLevel) { var z = $('#js_zoom_' + zoomLevel); slider.slider('value', 6 - z.index()); self.statsOptionsCell.update({ zoom: zoomLevel }); }); })(); self.rawStatsCell = Cell.compute(function (v) { if (v.need(DAL.cells.mode) != "analytics") { return; } var options = v.need(statsOptionsCell); var node; var bucket = v.need(statsBucketDetails).name; var data = _.extend({bucket: bucket}, options); var statName = v(statsStatName); if (statName) { data.statName = statName; } else if ((node = v(statsHostname))) { // we don't send node it we're dealing with "specific stats" and // we're careful to depend on statsHostname cell _only_ we're // willing to send node. data.node = node; } var bufferDepth = v.need(self.samplesBufferDepth); return createSamplesFuture(data, bufferDepth); }); self.displayingSpecificStatsCell = Cell.compute(function (v) { return !!(v.need(self.rawStatsCell).specificStatName); }); self.directoryURLCell = Cell.compute(function (v) { return v.need(self.rawStatsCell).directory.url; }); self.directoryURLCell.equality = function (a, b) {return a === b;}; self.directoryValueCell = Cell.compute(function (v) { return v.need(self.rawStatsCell).directory.value; }); self.directoryValueCell.equality = _.isEqual; self.directoryCell = Cell.compute(function (v) { var url = v.need(self.directoryURLCell); if (url) { return future.get({url: url}); } return v.need(self.directoryValueCell); }); self.specificStatTitleCell = Cell.compute(function (v) { return v.need(self.rawStatsCell).directory.origTitle; }); self.infosCell = Cell.needing(self.directoryCell).compute(function (v, statDesc) { statDesc = JSON.parse(JSON.stringify(statDesc)); // this makes deep copy of statDesc var infos = []; infos.byName = {}; var statItems = []; var blockIDs = []; var hadServerResources = false; if (statDesc.blocks[0].serverResources) { // We want it last so that default stat name (which is first // statItems entry) is not from ServerResourcesBlock hadServerResources = true; statDesc.blocks = statDesc.blocks.slice(1).concat([statDesc.blocks[0]]); } _.each(statDesc.blocks, function (aBlock) { var blockName = aBlock.blockName; aBlock.id = _.uniqueId("GB"); blockIDs.push(aBlock.id); var stats = aBlock.stats; statItems = statItems.concat(stats); _.each(stats, function (statInfo) { statInfo.id = _.uniqueId("G"); statInfo.blockId = aBlock.id; }); }); // and now make ServerResourcesBlock first for rendering if (hadServerResources) { statDesc.blocks.unshift(statDesc.blocks.pop()); } _.each(statItems, function (item) { infos.push(item); infos.byName[item.name] = item; }); infos.blockIDs = blockIDs; var infosByTitle = _.groupBy(infos, "title"); _.each(infos, function (statInfo) { if (statInfo.missing || statInfo.bigTitle) { return; } var title = statInfo.title; var homonyms = infosByTitle[title]; if (homonyms.length == 1) { return; } var sameBlock = _.any(homonyms, function (otherInfo) { return otherInfo !== statInfo && otherInfo.blockId === statInfo.blockId; }); var blockInfo = _.detect(statDesc.blocks, function (blockCand) { return blockCand.id === statInfo.blockId; }); if (!blockInfo) { BUG(); } if (sameBlock && blockInfo.columns) { var idx = _.indexOf(blockInfo.stats, statInfo); if (idx < 0) { BUG(); } statInfo.bigTitle = blockInfo.columns[idx % 4] + ' ' + statInfo.title; } else { statInfo.bigTitle = (blockInfo.bigTitlePrefix || blockInfo.blockName) + ' ' + statInfo.title; } }); return {statDesc: statDesc, infos: infos}; }); self.statsDescInfoCell = Cell.needing(self.infosCell).compute(function (v, infos) { return infos.statDesc; }).name("statsDescInfoCell"); self.graphsConfigurationCell = Cell.compute(function (v) { var selectedGraphName = v(v.need(self.smallGraphSelectionCellCell)); var stats = v.need(self.rawStatsCell); var selected; var infos = v.need(self.infosCell).infos; if (selectedGraphName && (selectedGraphName in infos.byName)) { selected = infos.byName[selectedGraphName]; } else { selected = infos[0]; } var auxTS = {}; var samples = _.clone(stats.stats[stats.mainStatsBlock]); _.each(stats.stats, function (subSamples, subName) { if (subName === stats.mainStatsBlock) { return; } var timestamps = subSamples.timestamp; for (var k in subSamples) { if (k == "timestamp") { continue; } samples[k] = subSamples[k]; auxTS[k] = timestamps; } }); if (!samples[selected.name]) { selected = _.detect(infos, function (info) {return samples[info.name];}) || selected; } return { interval: stats.interval, zoomLevel: v.need(zoomLevel), selected: selected, samples: samples, timestamp: samples.timestamp, auxTimestamps: auxTS, serverDate: stats.serverDate, clientDate: stats.clientDate, infos: infos, extra: v(self.configurationExtra) }; }); self.statsNodesCell = Cell.compute(function (v) { return _.filter(v.need(DAL.cells.serversCell).active, function (node) { return node.clusterMembership !== 'inactiveFailed' && node.status !== 'unhealthy'; }); }); self.hotKeysCell = Cell.computeEager(function (v) { if (!v(self.statsBucketDetails)) { // this deals with "no buckets at all" case for us return []; } return v.need(self.rawStatsCell).hot_keys || []; }); self.hotKeysCell.equality = _.isEqual; Cell.autonameCells(self); })(StatsModel); var maybeReloadAppDueToLeak = (function () { var counter = 300; return function () { if (!window.G_vmlCanvasManager) return; if (!--counter) reloadPage(); }; })(); ;(function (global) { var queuedUpdates = []; function flushQueuedUpdate() { var i = queuedUpdates.length; while (--i >= 0) { queuedUpdates[i](); } queuedUpdates.length = 0; } var shadowSize = 3; if (window.G_vmlCanvasManager) { shadowSize = 0; } function renderSmallGraph(jq, options) { function reqOpt(name) { var rv = options[name]; if (rv === undefined) throw new Error("missing option: " + name); return rv; } var data = reqOpt('data'); var now = reqOpt('now'); var plotSeries = buildPlotSeries(data, reqOpt('timestamp'), reqOpt('breakInterval'), reqOpt('timeOffset')).plotSeries; var lastY = data[data.length-1]; var maxString = isNaN(lastY) ? 'N/A' : ViewHelpers.formatQuantity(lastY, options.isBytes ? 1024 : 1000); queuedUpdates.push(function () { jq.find('#js_small_graph_value').text(maxString); }); if (queuedUpdates.length == 1) { setTimeout(flushQueuedUpdate, 0); } var color = reqOpt('isSelected') ? '#e2f1f9' : '#d95e28'; var yaxis = {min:0, ticks:0, autoscaleMargin: 0.04} if (options.maxY) yaxis.max = options.maxY; $.plot(jq.find('#js_small_graph_block'), _.map(plotSeries, function (plotData) { return {color: color, shadowSize: shadowSize, data: plotData}; }), {xaxis: {ticks:0, autoscaleMargin: 0.04, min: now - reqOpt('zoomMillis'), max: now}, yaxis: yaxis, grid: {show:false}}); } global.renderSmallGraph = renderSmallGraph; })(this); var GraphsWidget = mkClass({ initialize: function (largeGraphJQ, smallGraphsContainerJQ, descCell, configurationCell, isBucketAvailableCell) { this.largeGraphJQ = largeGraphJQ; this.smallGraphsContainerJQ = smallGraphsContainerJQ; this.drawnDesc = this.drawnConfiguration = {}; Cell.subscribeMultipleValues($m(this, 'renderAll'), descCell, configurationCell, isBucketAvailableCell); }, // renderAll (and subscribeMultipleValues) exist to strictly order renderStatsBlock w.r.t. updateGraphs renderAll: function (desc, configuration, isBucketAvailable) { if (this.drawnDesc !== desc) { this.renderStatsBlock(desc); this.drawnDesc = desc; } if (this.drawnConfiguration !== configuration) { this.updateGraphs(configuration); this.drawnConfiguration = configuration; } if (!isBucketAvailable) { this.unrenderNothing(); this.largeGraphJQ.html(''); this.smallGraphsContainerJQ.html(''); $('#js_analytics .js_current-graph-name').text(''); $('#js_analytics .js_current-graph-desc').text(''); } }, unrenderNothing: function () { if (this.spinners) { _.each(this.spinners, function (s) {s.remove()}); this.spinners = null; } }, renderNothing: function () { if (this.spinners) { return; } this.spinners = [ overlayWithSpinner(this.largeGraphJQ, undefined, undefined, 1) ]; this.smallGraphsContainerJQ.find('#js_small_graph_value').text('?') }, renderStatsBlock: function (descValue) { if (!descValue) { this.smallGraphsContainerJQ.html(''); this.renderNothing(); return; } this.unrenderNothing(); renderTemplate('js_new_stats_block', descValue, this.smallGraphsContainerJQ[0]); $(this).trigger('menelaus.graphs-widget.rendered-stats-block'); }, zoomToSeconds: { minute: 60, hour: 3600, day: 86400, week: 691200, month: 2678400, year: 31622400 }, forceNextRendering: function () { this.lastCompletedTimestamp = undefined; }, updateGraphs: function (configuration) { var self = this; if (!configuration) { self.lastCompletedTimestamp = undefined; return self.renderNothing(); } self.unrenderNothing(); var nowTStamp = (new Date()).valueOf(); if (self.lastCompletedTimestamp && nowTStamp - self.lastCompletedTimestamp < 200) { // skip this sample as we're too slow return; } var stats = configuration.samples; var timeOffset = configuration.clientDate - configuration.serverDate; var zoomMillis = (self.zoomToSeconds[configuration.zoomLevel] || 60) * 1000; var selected = configuration.selected; var now = (new Date()).valueOf(); if (configuration.interval < 2000) { now -= StatsModel.samplesBufferDepth.value * 1000; } maybeReloadAppDueToLeak(); var auxTS = configuration.auxTimestamps || {}; plotStatGraph(self.largeGraphJQ, stats[selected.name], auxTS[selected.name] || configuration.timestamp, { color: '#1d88ad', verticalMargin: 1.02, fixedTimeWidth: zoomMillis, timeOffset: timeOffset, lastSampleTime: now, breakInterval: configuration.interval * 2.5, maxY: configuration.infos.byName[selected.name].maxY, isBytes: configuration.selected.isBytes }); try { var visibleBlockIDs = {}; _.each($(_.map(configuration.infos.blockIDs, $i)).filter(":has(.js_stats:visible)"), function (e) { visibleBlockIDs[e.id] = e; }); } catch (e) { debugger throw e; } _.each(configuration.infos, function (statInfo) { if (!visibleBlockIDs[statInfo.blockId]) { return; } var statName = statInfo.name; var graphContainer = $($i(statInfo.id)); if (graphContainer.length == 0) { return; } renderSmallGraph(graphContainer, { data: stats[statName] || [], breakInterval: configuration.interval * 2.5, timeOffset: timeOffset, now: now, zoomMillis: zoomMillis, isSelected: selected.name == statName, timestamp: auxTS[statName] || configuration.timestamp, maxY: configuration.infos.byName[statName].maxY, isBytes: statInfo.isBytes }); }); self.lastCompletedTimestamp = (new Date()).valueOf(); $(self).trigger('menelaus.graphs-widget.rendered-graphs'); } }); var AnalyticsSection = { onKeyStats: function (hotKeys) { renderTemplate('js_top_keys', _.map(hotKeys, function (e) { return $.extend({}, e, {total: 0 + e.gets + e.misses}); })); }, init: function () { var self = this; StatsModel.hotKeysCell.subscribeValue($m(self, 'onKeyStats')); prepareTemplateForCell('js_top_keys', StatsModel.hotKeysCell); StatsModel.displayingSpecificStatsCell.subscribeValue(function (displayingSpecificStats) { $('#js_top_keys_block').toggle(!displayingSpecificStats); }); $('#js_analytics .js_block-expander').live('click', function () { // this forces configuration refresh and graphs redraw self.widget.forceNextRendering(); StatsModel.configurationExtra.setValue({}); }); IOCenter.staleness.subscribeValue(function (stale) { $('#js_stats-period-container')[stale ? 'hide' : 'show'](); $('#js_analytics .js_staleness-notice')[stale ? 'show' : 'hide'](); }); (function () { var cell = Cell.compute(function (v) { var mode = v.need(DAL.cells.mode); if (mode != 'analytics') { return; } var allBuckets = v.need(DAL.cells.bucketsListCell); var selectedBucket = v(StatsModel.statsBucketDetails); return {list: _.map(allBuckets, function (info) {return [info.uri, info.name]}), selected: selectedBucket && selectedBucket.uri}; }); $('#js_analytics_buckets_select').bindListCell(cell, { onChange: function (e, newValue) { StatsModel.statsBucketURL.setValue(newValue); } }); })(); (function () { var cell = Cell.compute(function (v) { var mode = v.need(DAL.cells.mode); if (mode != 'analytics') { return; } var allNodes = v(StatsModel.statsNodesCell); var statsHostname = v(StatsModel.statsHostname); var list; if (allNodes) { list = _.map(allNodes, function (srv) { var name = ViewHelpers.maybeStripPort(srv.hostname, allNodes); return [srv.hostname, name]; }); // natural sort by full hostname (which includes port number) list.sort(mkComparatorByProp(0, naturalSort)); list.unshift(['', 'All Server Nodes (' + allNodes.length + ')' ]); } return {list: list, selected: statsHostname}; }); $('#js_analytics_servers_select').bindListCell(cell, { onChange: function (e, newValue) { StatsModel.statsHostname.setValue(newValue || undefined); } }); })(); self.widget = new GraphsWidget( $('#js_analytics_main_graph'), $('#js_stats_container'), StatsModel.statsDescInfoCell, StatsModel.graphsConfigurationCell, DAL.cells.isBucketsAvailableCell); Cell.needing(StatsModel.graphsConfigurationCell).compute(function (v, configuration) { return configuration.timestamp.length == 0; }).subscribeValue(function (missingSamples) { $('#js_stats-period-container').toggleClass('dynamic_missing-samples', !!missingSamples); }); Cell.needing(StatsModel.graphsConfigurationCell).compute(function (v, configuration) { var zoomMillis = GraphsWidget.prototype.zoomToSeconds[configuration.zoomLevel] * 1000; return Math.ceil(Math.min(zoomMillis, configuration.serverDate - configuration.timestamp[0]) / 1000); }).subscribeValue(function (visibleSeconds) { $('#js_stats_visible_period').text(isNaN(visibleSeconds) ? '?' : formatUptime(visibleSeconds)); }); (function () { var selectionCell; StatsModel.smallGraphSelectionCellCell.subscribeValue(function (cell) { selectionCell = cell; }); $(".js_analytics-small-graph").live("click", function (e) { // don't intercept right arrow clicks if ($(e.target).is(".js_right-arrow, .js_right-arrow *")) { return; } e.preventDefault(); var graphParam = this.getAttribute('data-graph'); if (!graphParam) { debugger throw new Error("shouldn't happen"); } if (!selectionCell) { return; } selectionCell.setValue(graphParam); self.widget.forceNextRendering(); }); })(); (function () { function handler() { var val = effectiveSelected.value; val = val && val.name; $('.js_analytics-small-graph.dynamic_selected').removeClass('dynamic_selected'); if (!val) { return; } $(_.filter($('.js_analytics-small-graph[data-graph]'), function (el) { return String(el.getAttribute('data-graph')) === val; })).addClass('dynamic_selected'); } var effectiveSelected = Cell.compute(function (v) {return v.need(StatsModel.graphsConfigurationCell).selected}); effectiveSelected.subscribeValue(handler); $(self.widget).bind('menelaus.graphs-widget.rendered-stats-block', handler); })(); $(self.widget).bind('menelaus.graphs-widget.rendered-graphs', function () { var graph = StatsModel.graphsConfigurationCell.value.selected; $('#js_analytics .js_current-graph-name').text(graph.bigTitle || graph.title); $('#js_analytics .js_current-graph-desc').text(graph.desc); }); $(self.widget).bind('menelaus.graphs-widget.rendered-stats-block', function () { $('#js_stats_container').hide(); _.each($('.js_analytics-small-graph:not(.dynamic_dim)'), function (e) { e = $(e); var graphParam = e.attr('data-graph'); if (!graphParam) { debugger throw new Error("shouldn't happen"); } var ul = e.find('.js_right-arrow .js_inner').need(1); var params = {sec: 'analytics', statsBucket: StatsModel.statsBucketDetails.value.uri}; var aInner; if (!StatsModel.displayingSpecificStatsCell.value) { params.statsStatName = graphParam; aInner = "show by server"; } else { params.graph = StatsModel.statsStatName.value; params.statsHostname = graphParam.slice(1); aInner = "show this server"; } ul[0].appendChild(jst.analyticsRightArrow(aInner, params)); }); $('#js_stats_container').show(); }); StatsModel.displayingSpecificStatsCell.subscribeValue(function (displayingSpecificStats) { displayingSpecificStats = !!displayingSpecificStats; $('#js_analytics .js_when-normal-stats').toggle(!displayingSpecificStats); $('#js_analytics .js_when-specific-stats').toggle(displayingSpecificStats); }); StatsModel.specificStatTitleCell.subscribeValue(function (val) { var text = val || '?'; $('.js_specific-stat-description').text(text); }); }, onLeave: function () { setHashFragmentParam("zoom", undefined); StatsModel.statsHostname.setValue(undefined); StatsModel.statsBucketURL.setValue(undefined); StatsModel.selectedGraphNameCell.setValue(undefined); StatsModel.statsStatName.setValue(undefined); }, onEnter: function () { } };
TOTVS/mdmpublic
couchbase-cli/lib/ns_server/erlang/lib/ns_server/priv/public/js/analytics.js
JavaScript
bsd-2-clause
26,506
# Copyright (c) 2012-2021, Mark Peek <mark@peek.org> # All rights reserved. # # See LICENSE file for full license. from .aws import Action as BaseAction from .aws import BaseARN service_name = "Amazon Mechanical Turk" prefix = "mechanicalturk" class Action(BaseAction): def __init__(self, action: str = None) -> None: super().__init__(prefix, action) class ARN(BaseARN): def __init__(self, resource: str = "", region: str = "", account: str = "") -> None: super().__init__( service=prefix, resource=resource, region=region, account=account ) AcceptQualificationRequest = Action("AcceptQualificationRequest") ApproveAssignment = Action("ApproveAssignment") ApproveRejectedAssignment = Action("ApproveRejectedAssignment") AssignQualification = Action("AssignQualification") AssociateQualificationWithWorker = Action("AssociateQualificationWithWorker") BlockWorker = Action("BlockWorker") ChangeHITTypeOfHIT = Action("ChangeHITTypeOfHIT") CreateAdditionalAssignmentsForHIT = Action("CreateAdditionalAssignmentsForHIT") CreateHIT = Action("CreateHIT") CreateHITType = Action("CreateHITType") CreateHITWithHITType = Action("CreateHITWithHITType") CreateQualificationType = Action("CreateQualificationType") CreateWorkerBlock = Action("CreateWorkerBlock") DeleteHIT = Action("DeleteHIT") DeleteQualificationType = Action("DeleteQualificationType") DeleteWorkerBlock = Action("DeleteWorkerBlock") DisableHIT = Action("DisableHIT") DisassociateQualificationFromWorker = Action("DisassociateQualificationFromWorker") DisposeHIT = Action("DisposeHIT") DisposeQualificationType = Action("DisposeQualificationType") ExtendHIT = Action("ExtendHIT") ForceExpireHIT = Action("ForceExpireHIT") GetAccountBalance = Action("GetAccountBalance") GetAssignment = Action("GetAssignment") GetAssignmentsForHIT = Action("GetAssignmentsForHIT") GetBlockedWorkers = Action("GetBlockedWorkers") GetBonusPayments = Action("GetBonusPayments") GetFileUploadURL = Action("GetFileUploadURL") GetHIT = Action("GetHIT") GetHITsForQualificationType = Action("GetHITsForQualificationType") GetQualificationRequests = Action("GetQualificationRequests") GetQualificationScore = Action("GetQualificationScore") GetQualificationType = Action("GetQualificationType") GetQualificationsForQualificationType = Action("GetQualificationsForQualificationType") GetRequesterStatistic = Action("GetRequesterStatistic") GetRequesterWorkerStatistic = Action("GetRequesterWorkerStatistic") GetReviewResultsForHIT = Action("GetReviewResultsForHIT") GetReviewableHITs = Action("GetReviewableHITs") GrantBonus = Action("GrantBonus") GrantQualification = Action("GrantQualification") ListAssignmentsForHIT = Action("ListAssignmentsForHIT") ListBonusPayments = Action("ListBonusPayments") ListHITs = Action("ListHITs") ListHITsForQualificationType = Action("ListHITsForQualificationType") ListQualificationRequests = Action("ListQualificationRequests") ListQualificationTypes = Action("ListQualificationTypes") ListReviewPolicyResultsForHIT = Action("ListReviewPolicyResultsForHIT") ListReviewableHITs = Action("ListReviewableHITs") ListWorkerBlocks = Action("ListWorkerBlocks") ListWorkersWithQualificationType = Action("ListWorkersWithQualificationType") NotifyWorkers = Action("NotifyWorkers") RegisterHITType = Action("RegisterHITType") RejectAssignment = Action("RejectAssignment") RejectQualificationRequest = Action("RejectQualificationRequest") RevokeQualification = Action("RevokeQualification") SearchHITs = Action("SearchHITs") SearchQualificationTypes = Action("SearchQualificationTypes") SendBonus = Action("SendBonus") SendTestEventNotification = Action("SendTestEventNotification") SetHITAsReviewing = Action("SetHITAsReviewing") SetHITTypeNotification = Action("SetHITTypeNotification") UnblockWorker = Action("UnblockWorker") UpdateExpirationForHIT = Action("UpdateExpirationForHIT") UpdateHITReviewStatus = Action("UpdateHITReviewStatus") UpdateHITTypeOfHIT = Action("UpdateHITTypeOfHIT") UpdateNotificationSettings = Action("UpdateNotificationSettings") UpdateQualificationScore = Action("UpdateQualificationScore") UpdateQualificationType = Action("UpdateQualificationType")
cloudtools/awacs
awacs/mechanicalturk.py
Python
bsd-2-clause
4,190
package com.rustyrazorblade.graph; /** * Created by jhaddad on 6/7/14. */ public class Edge extends Element { Vertex in, out; String label; public Edge(String label, Vertex in, Vertex out) { this.in = in; this.out = out; this.label = label; } }
rustyrazorblade/javagraph
src/com/rustyrazorblade/graph/Edge.java
Java
bsd-2-clause
289
-- |Interactions with the user. module Ovid.Interactions ( tell , options ) where import Ovid.Prelude import qualified System.Console.Editline.Readline as R -- |Prompt the user. tell s = liftIO (putStrLn s) -- |Asks the user to pick an item from a list. options :: (MonadIO m, Show a) => [a] -> m a options xs = do let numOptions = length xs let showOption (n,x) = tell $ show n ++ " - " ++ show x mapM_ showOption (zip [1..] xs) tell $ "Select one (1 .. " ++ show numOptions ++ ") >" let makeSelection = do ch <- liftIO $ R.readKey case tryInt "ch" of Nothing -> do tell $ "Enter a number between 1 and " ++ show numOptions makeSelection Just n -> if n >= 1 && n <= numOptions then return (xs !! (n-1)) else do tell $ "Enter a number between 1 and " ++ show numOptions makeSelection makeSelection
brownplt/ovid
src/Ovid/Interactions.hs
Haskell
bsd-2-clause
972
<?php /** * Copyright 2011 Bas de Nooijer. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this listof conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER 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. * * The views and conclusions contained in the software and documentation are * those of the authors and should not be interpreted as representing official * policies, either expressed or implied, of the copyright holder. * * @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl> * @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @link http://www.solarium-project.org/ */ /** * @namespace */ namespace Solarium\QueryType\Schema\Query\Command; use Solarium\Core\ArrayableInterface; use Solarium\Core\Configurable; use Solarium\Exception\InvalidArgumentException; /** * Schema query command base class * @author Beno!t POLASZEK */ abstract class Command extends Configurable implements ArrayableInterface { /** * Returns command type, for use in adapters * * @return string */ abstract public function getType(); abstract public function castAsArray(); }
bpolaszek/solarium
library/Solarium/QueryType/Schema/Query/Command/Command.php
PHP
bsd-2-clause
2,307
module.exports = function notEmpty(o) { if (o == null) { return false; } else if (Array.isArray(o)) { return !!o.length; } else if (o === '') { return false; } return true; };
ticolucci/dotfiles
atom/packages/atom-beautify/node_modules/marko/helpers/notEmpty.js
JavaScript
bsd-2-clause
220
# hsup [DEPRECATED] _This project is officially retired and no longer maintained._ Supervises processes that are configured in a Heroku-esque way. `hsup` can poll the Heroku API directly to obtain releases, configuration, and execution information. `hsup` can also watch a local directory that injects similar information. The execution is performed with a chosen "dyno driver": * The default dyno driver, `simple`, downloads and refreshes the environment only. * The `docker` dyno driver both obtains the environment and executable code and runs it interposed on the `heroku/cedar:14` image. * The `libcontainer` driver is similar to the Docker driver, but runs containers in foreground, on top of Heroku official (read only) stack images. It needs to be executed as root (e.g.: `sudo`) and only works on Linux machines. See notes about running it in Docker (below) for nested (hsup-in-docker) support and execution on any host with Docker installed (e.g.: boot2docker). Usage: ``` sh hsup COMMAND [options] [args...] ``` Where `COMMAND` is on one: * `run`: Run a command with an app's environment. * `start`: Start a process type as defined in an app's `Procfile`. Example: ``` sh godep go install ./... export DOCKER_HOST=unix:///var/run/docker.sock export HEROKU_ACCESS_TOKEN=... # start default process types inside Docker hsup start -d docker start -a simple-brandur # run command as subprocess hsup run -d simple -a simple-brandur -- echo "hello" ``` Example using a directory: ```sh godep go install ./... export HSUP_CONTROL_DIR=/tmp/supctl mkdir -p "$HSUP_CONTROL_DIR" echo '{ "Version": 1, "Env": { "NAME": "CONTENTS" }, "Slug": "sample-slug.tgz", "Stack": "cedar-14", "Processes": [ { "Args": ["./web-server", "arg"], "Quantity": 2, "Type": "web" }, { "Args": ["./worker", "arg"], "Quantity": 2, "Type": "worker" } ] }' > "$HSUP_CONTROL_DIR"/new hsup run '/usr/bin/printenv' # Note that after verifying the input, the file is moved to "loaded". # Writing new "new" files is how updates can be issued. ls "$HSUP_CONTROL_DIR" ``` ## Running the libcontainer driver within Docker If you are using boot2docker, do the necessary preparation to expand the available disk space for hsup data: ```sh-session $ make boot2docker-init ``` Containers (hsup/libcontainer) inside containers (docker). Inception! ```sh-session $ docker build -t hsup . $ docker run --privileged -it hsup # will run /usr/bin/printenv, see docker/example.json for details ``` The docker container by default runs `hsup start --oneshot`. For a custom hsup command, use: ```sh-session $ docker run --privileged -it hsup run bash (dyno console) ~ $ ``` Stack images will be downloaded for each new fresh container. It is a good idea to share a common stack image directory between all containers to avoid downloading them every time: ```sh-session $ docker run --privileged -v /var/lib/hsup:/var/lib/hsup -it hsup ``` A custom hsup control dir can be injected as a docker volume, in case custom json control files are required: ```sh-session $ docker run --privileged -v /tmp/supctl:/etc/hsup -v /tmp/stacks:/var/lib/hsup/stacks -it hsup (/tmp/supctl/new or /tmp/supctl/loaded will be used as the control file) ``` ## Automated functional tests If you are using boot2docker (check the section above for details): ```sh-session $ make boot2docker-init ``` To run several functional tests against a `hsup` binary: ```sh-session $ godep go test ./ftest -driver docker -hsup <path-to-compiled-hsup-binary> ``` Different drivers (`libcontainer`, `simple`) can be specified with the `driver` flag, but note that the libcontainer driver requires `root` privileges: ```sh-session $ sudo -E $(which godep) go test ./ftest -driver libcontainer -hsup <path-to-hsup-binary> ``` All tests can also be executed inside docker containers (see the hsup-inside-docker section above) with: ```sh-session $ make ftest runs libcontainer driver tests by default $ make ftest driver=docker specify a custom driver $ make ftest-libcontainer libcontainer driver tests... $ make ftest-docker docker driver tests... $ make ftest-simple simple driver tests... ``` ## Driver specific configuration Some drivers accept custom configuration via ENV. ### Docker * `DOCKER_HOST` * `DOCKER_CERT_PATH` * `DOCKER_IMAGE_CACHE`: when set, docker images are only built once per release. ### Libcontainer * `LIBCONTAINER_DYNO_SUBNET`: a CIDR block to allocate dyno subnets (of size /30) from. It is `172.16.0.0/12` (RFC1918) by default when not set. * `LIBCONTAINER_DYNO_EXTRA_INTERFACE`: interface on the host to inject into the dyno (currently as a [ipvlan][ipvlan] subinterface), together with its IP address CIDR in the format: `hostIFName:IP/Mask`. Eg.: `eth1:10.0.0.10/24`. * `LIBCONTAINER_DYNO_EXTRA_ROUTES`: extra routes to add to the dyno network namespace main routing table. Format: `IP/Mask:Gateway:IF,IP/Mask:Gateway,IF,...`, example: `10.0.0.0/8:10.1.1.1:eth1,192.168.0.0/24:default:eth0`. The special value `default` can be used as the gateway, and will be replaced with the dyno's default route gateway at runtime. * `LIBCONTAINER_DYNO_UID_MIN` and `LIBCONTAINER_DYNO_UID_MAX`: Linux UIDs to use for each dyno. It also defines the maximum number of allowed dynos, as each dyno gets a unique UID per box. To avoid reusing subnets (IPs), make sure that `(maxUID - minUID) <= /30 subnets that LIBCONTAINER_DYNO_SUBNET can provide`. `172.17.0.0/16` can provide `2 ** (30-16)` = **16384** subnets of size /30. In this case, to avoid subnets being reused, make sure that `(maxUID - minUID) <= 16384`. [ipvlan]: https://github.com/torvalds/linux/blob/master/Documentation/networking/ipvlan.txt
heroku/hsup
README.md
Markdown
bsd-2-clause
5,862
# Copyright (c) 2020, DjaoDjin inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. 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. # # 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. import logging from rest_framework import generics from ..mixins import CampaignMixin from .serializers import CampaignSerializer LOGGER = logging.getLogger(__name__) class CampaignAPIView(CampaignMixin, generics.RetrieveDestroyAPIView): """ Retrieves a campaign Retrieves the details of a ``Campaign``. **Tags**: survey **Examples** .. code-block:: http GET /api/cowork/campaign/best-practices/ HTTP/1.1 responds .. code-block:: json { "slug": "best-practices", "account": "envconnect", "title": "Assessment on Best Practices", "active": true, "quizz_mode": false, "questions": [ { "path": "/product-design", "title": "Product Design", "unit": "assessment-choices", }, { "path": "/packaging-design", "title": "Packaging Design", "unit": "assessment-choices", } ] } """ serializer_class = CampaignSerializer def get_object(self): return self.campaign def delete(self, request, *args, **kwargs): """ Deletes a campaign Removes a ``Campaign`` and all associated ``Sample`` from the database. **Tags**: survey **Examples** .. code-block:: http DELETE /api/cowork/campaign/best-practices/ HTTP/1.1 """ #pylint:disable=useless-super-delegation return super(CampaignAPIView, self).delete(request, *args, **kwargs)
djaodjin/djaodjin-survey
survey/api/campaigns.py
Python
bsd-2-clause
3,013
package com.seatgeek.placesautocomplete.json; import android.util.JsonReader; import com.seatgeek.placesautocomplete.model.AddressComponent; import com.seatgeek.placesautocomplete.model.AddressComponentType; import com.seatgeek.placesautocomplete.model.AlternativePlaceId; import com.seatgeek.placesautocomplete.model.DateTimePair; import com.seatgeek.placesautocomplete.model.DescriptionTerm; import com.seatgeek.placesautocomplete.model.MatchedSubstring; import com.seatgeek.placesautocomplete.model.OpenHours; import com.seatgeek.placesautocomplete.model.OpenPeriod; import com.seatgeek.placesautocomplete.model.Place; import com.seatgeek.placesautocomplete.model.PlaceDetails; import com.seatgeek.placesautocomplete.model.PlaceGeometry; import com.seatgeek.placesautocomplete.model.PlaceLocation; import com.seatgeek.placesautocomplete.model.PlacePhoto; import com.seatgeek.placesautocomplete.model.PlaceReview; import com.seatgeek.placesautocomplete.model.PlaceScope; import com.seatgeek.placesautocomplete.model.PlaceType; import com.seatgeek.placesautocomplete.model.RatingAspect; import com.seatgeek.placesautocomplete.model.Status; import org.junit.Before; import org.junit.Test; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class AndroidPlacesApiJsonParserTest { private AndroidPlacesApiJsonParser parser; private JsonReader reader; @Before public void setUp() { parser = mock(AndroidPlacesApiJsonParser.class); reader = mock(JsonReader.class); } @Test public void readPlaceTypesArrayTest() throws IOException { when(parser.readPlaceTypesArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, false); when(reader.nextString()).thenReturn("route", "geocode", "skip"); List<PlaceType> expected = Arrays.asList(PlaceType.ROUTE, PlaceType.GEOCODE); List<PlaceType> actual = parser.readPlaceTypesArray(reader); assertEquals(expected, actual); } @Test public void readDescriptionTermsArrayTest() throws IOException { when(parser.readDescriptionTermsArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, false, true, false, false); when(reader.nextName()).thenReturn("offset", "value", "skip"); when(reader.nextInt()).thenReturn(1); when(reader.nextString()).thenReturn("one"); List<DescriptionTerm> expected = Arrays.asList(new DescriptionTerm(1, "one"), new DescriptionTerm(-1, null)); List<DescriptionTerm> actual = parser.readDescriptionTermsArray(reader); assertEquals(expected, actual); } @Test public void readMatchedSubstringsArrayTest() throws IOException { when(parser.readMatchedSubstringsArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, false, true, false, false); when(reader.nextName()).thenReturn("length", "offset", "skip"); when(reader.nextInt()).thenReturn(1, 2); List<MatchedSubstring> expected = Arrays.asList(new MatchedSubstring(1, 2), new MatchedSubstring(-1, -1)); List<MatchedSubstring> actual = parser.readMatchedSubstringsArray(reader); assertEquals(expected, actual); } @Test public void readPlaceTest() throws IOException { when(parser.readPlace(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, true, true, false); when(reader.nextName()).thenReturn("description", "place_id", "matched_substrings", "terms", "types", "skip"); when(reader.nextString()).thenReturn("desc", "id"); List<MatchedSubstring> substrings = Collections.singletonList(new MatchedSubstring(1, 2)); when(parser.readMatchedSubstringsArray(reader)).thenReturn(substrings); List<DescriptionTerm> terms = Collections.singletonList(new DescriptionTerm(3, "three")); when(parser.readDescriptionTermsArray(reader)).thenReturn(terms); List<PlaceType> types = Arrays.asList(PlaceType.ROUTE, PlaceType.GEOCODE); when(parser.readPlaceTypesArray(reader)).thenReturn(types); Place expected = new Place("desc", "id", substrings, terms, types); Place actual = parser.readPlace(reader); assertEquals(expected, actual); } @Test public void readStatusTest() throws IOException { when(parser.readStatus(reader)).thenCallRealMethod(); when(reader.nextString()).thenReturn("OK", "ZERO_RESULTS", "OVER_QUERY_LIMIT", "REQUEST_DENIED", "INVALID_REQUEST", "skip"); assertEquals(Status.OK, parser.readStatus(reader)); assertEquals(Status.ZERO_RESULTS, parser.readStatus(reader)); assertEquals(Status.OVER_QUERY_LIMIT, parser.readStatus(reader)); assertEquals(Status.REQUEST_DENIED, parser.readStatus(reader)); assertEquals(Status.INVALID_REQUEST, parser.readStatus(reader)); assertNull(parser.readStatus(reader)); } @Test public void readTypesArrayTest() throws IOException { when(parser.readTypesArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, false); when(reader.nextString()).thenReturn("one", "two", "three"); List<String> expected = Arrays.asList("one", "two", "three"); List<String> actual = parser.readTypesArray(reader); assertEquals(expected, actual); } @Test public void readAspectsArrayTest() throws IOException { when(parser.readAspectsArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, false, true, false, false); when(reader.nextName()).thenReturn("rating", "type", "skip"); when(reader.nextInt()).thenReturn(1); when(reader.nextString()).thenReturn("one"); List<RatingAspect> expected = Arrays.asList(new RatingAspect(1, "one"), new RatingAspect(-1, null)); List<RatingAspect> actual = parser.readAspectsArray(reader); assertEquals(expected, actual); } @Test public void readReviewsArrayTest() throws IOException { when(parser.readReviewsArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, true, true, true, true, true, true, false, true, false, false); when(reader.nextName()).thenReturn("aspects", "author_name", "author_url", "language", "rating", "text", "time", "skip"); List<RatingAspect> aspects = Arrays.asList(new RatingAspect(1, "one"), new RatingAspect(-1, null)); when(parser.readAspectsArray(reader)).thenReturn(aspects); when(reader.nextString()).thenReturn("name", "url", "lang", "txt"); when(reader.nextInt()).thenReturn(1); when(reader.nextLong()).thenReturn(10L); List<PlaceReview> expected = Arrays.asList(new PlaceReview(aspects, "name", "url", "lang", 1, "txt", 10L), new PlaceReview(null, null, null, null, -1, null, -1L)); List<PlaceReview> actual = parser.readReviewsArray(reader); assertEquals(expected, actual); } @Test public void readAltIdsArrayTest() throws IOException { when(parser.readAltIdsArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, false, true, false, false); when(reader.nextName()).thenReturn("place_id", "scope", "skip"); when(reader.nextString()).thenReturn("id"); when(parser.readScope(reader)).thenReturn(PlaceScope.GOOGLE); List<AlternativePlaceId> expected = Arrays.asList(new AlternativePlaceId("id", PlaceScope.GOOGLE), new AlternativePlaceId(null, null)); List<AlternativePlaceId> actual = parser.readAltIdsArray(reader); assertEquals(expected, actual); } @Test public void readScopeTest() throws IOException { when(parser.readScope(reader)).thenCallRealMethod(); when(reader.nextString()).thenReturn("APP", "GOOGLE", "skip"); assertEquals(PlaceScope.APP, parser.readScope(reader)); assertEquals(PlaceScope.GOOGLE, parser.readScope(reader)); assertNull(parser.readScope(reader)); } @Test public void readPhotosArrayTest() throws IOException { when(parser.readPhotosArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, true, false, true, false, false); when((reader.nextName())).thenReturn("height", "width", "photo_reference", "skip"); when(reader.nextInt()).thenReturn(1, 2); when(reader.nextString()).thenReturn("photo"); List<PlacePhoto> expected = Arrays.asList(new PlacePhoto(1, 2, "photo"), new PlacePhoto(-1, -1, null)); List<PlacePhoto> actual = parser.readPhotosArray(reader); assertEquals(expected, actual); } @Test public void readDateTimePairTest() throws IOException { when(parser.readDateTimePair(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, false); when((reader.nextName())).thenReturn("day", "time", "skip"); when((reader.nextString())).thenReturn("one", "two"); DateTimePair expected = new DateTimePair("one", "two"); DateTimePair actual = parser.readDateTimePair(reader); assertEquals(expected, actual); } @Test public void readOpenPeriodsArrayTest() throws IOException { when(parser.readOpenPeriodsArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, false, true, false, false); when(reader.nextName()).thenReturn("open", "close", "skip"); when(parser.readDateTimePair(reader)).thenReturn(new DateTimePair("one", "two"), new DateTimePair("three", "four")); List<OpenPeriod> expected = Arrays.asList(new OpenPeriod(new DateTimePair("one", "two"), new DateTimePair("three", "four")), new OpenPeriod(null, null)); List<OpenPeriod> actual = parser.readOpenPeriodsArray(reader); assertEquals(expected, actual); } @Test public void readOpeningHoursTest() throws IOException { when(parser.readOpeningHours(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, false); when(reader.nextName()).thenReturn("open_now", "periods", "skip"); when(reader.nextBoolean()).thenReturn(true); List<OpenPeriod> periods = Collections.singletonList(new OpenPeriod(new DateTimePair("one", "two"), new DateTimePair("three", "four"))); when(parser.readOpenPeriodsArray(reader)).thenReturn(periods); OpenHours expected = new OpenHours(true, periods); OpenHours actual = parser.readOpeningHours(reader); assertEquals(expected, actual); } @Test public void readGeometryTest() throws IOException { when(parser.readGeometry(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, false); when(reader.nextName()).thenReturn("lat", "lng", "skip"); when(reader.nextDouble()).thenReturn(1.0, 2.0); PlaceGeometry expected = new PlaceGeometry(new PlaceLocation(1.0, 2.0)); PlaceGeometry actual = parser.readGeometry(reader); assertEquals(expected, actual); } @Test public void readAddressComponentTypesArrayTest() throws IOException { when(parser.readAddressComponentTypesArray(reader)).thenCallRealMethod(); // hasNext() should return true N times, where N is the number of AddressComponentTypes int numOfTypes = AddressComponentType.values().length; Boolean[] hasNextValues = new Boolean[numOfTypes + 1]; Arrays.fill(hasNextValues, 0, numOfTypes, Boolean.TRUE); hasNextValues[numOfTypes] = Boolean.FALSE; // indicate stop when(reader.hasNext()).thenReturn(true, hasNextValues); // initial true is for "skip" String[] types = new String[] { "administrative_area_level_1", "administrative_area_level_2", "administrative_area_level_3", "administrative_area_level_4", "administrative_area_level_5", "colloquial_area", "country", "floor", "geocode", "intersection", "locality", "natural_feature", "neighborhood", "political", "point_of_interest", "post_box", "postal_code", "postal_code_prefix", "postal_code_suffix", "postal_town", "premise", "room", "route", "street_address", "street_number", "sublocality", "sublocality_level_1", "sublocality_level_2", "sublocality_level_3", "sublocality_level_4", "sublocality_level_5", "subpremise", "transit_station" }; when(reader.nextString()).thenReturn("skip", types); List<AddressComponentType> expected = new ArrayList<>(); for (String type : types) { expected.add(AddressComponentType.valueOf(type.toUpperCase())); } List<AddressComponentType> actual = parser.readAddressComponentTypesArray(reader); assertEquals(expected, actual); } @Test public void readAddressComponentsArrayTest() throws IOException { when(parser.readAddressComponentsArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, true, true, false, true, false, false); when(reader.nextName()).thenReturn("long_name", "short_name", "types", "skip"); when(reader.nextString()).thenReturn("long", "short"); List<AddressComponentType> types = Arrays.asList(AddressComponentType.ROOM, AddressComponentType.FLOOR); when(parser.readAddressComponentTypesArray(reader)).thenReturn(types); List<AddressComponent> expected = Arrays.asList(new AddressComponent("long", "short", types), new AddressComponent(null, null, null)); List<AddressComponent> actual = parser.readAddressComponentsArray(reader); assertEquals(expected, actual); } @Test public void readPlaceDetailsTest() throws IOException { when(parser.readPlaceDetails(reader)).thenCallRealMethod(); Boolean[] hasNextValues = new Boolean[20]; Arrays.fill(hasNextValues, 0, 19, Boolean.TRUE); hasNextValues[19] = Boolean.FALSE; when(reader.hasNext()).thenReturn(true, hasNextValues); String[] names = new String[] { "address_components", "formatted_address", "formatted_phone_number", "international_phone_number", "geometry", "icon", "name", "place_id", "opening_hours", "permanently_closed", "photos", "scope", "alt_ids", "price_level", "rating", "reviews", "types", "url", "vicinity" }; when(reader.nextName()).thenReturn("skip", names); when(parser.readAddressComponentsArray(reader)).thenReturn(Collections.singletonList(new AddressComponent("long", "short", Collections.singletonList(AddressComponentType.ROOM)))); when(reader.nextString()).thenReturn("addr", "phone", "intl_phone", "icon", "name", "id", "url", "vic"); when(parser.readGeometry(reader)).thenReturn(new PlaceGeometry(new PlaceLocation(1.0, 2.0))); when(parser.readOpeningHours(reader)).thenReturn(new OpenHours(true, Collections.singletonList(new OpenPeriod(new DateTimePair("one", "two"), new DateTimePair("three", "four"))))); when(reader.nextBoolean()).thenReturn(true); when(parser.readPhotosArray(reader)).thenReturn(Collections.singletonList(new PlacePhoto(1, 2, "ref"))); when(parser.readScope(reader)).thenReturn(PlaceScope.GOOGLE); when(parser.readAltIdsArray(reader)).thenReturn(Collections.singletonList(new AlternativePlaceId("id", PlaceScope.GOOGLE))); when(reader.nextInt()).thenReturn(5); when(reader.nextDouble()).thenReturn(5.0); when(parser.readReviewsArray(reader)).thenReturn(Collections.singletonList(new PlaceReview(Collections.singletonList(new RatingAspect(5, "quality")), "name", "url", "en", 4, "txt", 10L))); when(parser.readTypesArray(reader)).thenReturn(Collections.singletonList("type")); PlaceDetails expected = new PlaceDetails(Collections.singletonList(new AddressComponent("long", "short", Collections.singletonList(AddressComponentType.ROOM))), "addr", "phone", "intl_phone", new PlaceGeometry(new PlaceLocation(1.0, 2.0)), "icon", "name", "id", new OpenHours(true, Collections.singletonList(new OpenPeriod(new DateTimePair("one", "two"), new DateTimePair("three", "four")))), true, Collections.singletonList(new PlacePhoto(1, 2, "ref")), PlaceScope.GOOGLE, Collections.singletonList(new AlternativePlaceId("id", PlaceScope.GOOGLE)), 5, 5.0, Collections.singletonList(new PlaceReview(Collections.singletonList(new RatingAspect(5, "quality")), "name", "url", "en", 4, "txt", 10L)), Collections.singletonList("type"), "url", "vic"); PlaceDetails actual = parser.readPlaceDetails(reader); assertEquals(expected, actual); } @Test public void readPredictionsArrayTest() throws IOException { when(parser.readPredictionsArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, false); Place place = new Place("desc", "id", Collections.singletonList(new MatchedSubstring(1, 2)), Collections.singletonList(new DescriptionTerm(3, "three")), Collections.singletonList(PlaceType.GEOCODE)); when(parser.readPlace(reader)).thenReturn(place); List<Place> expected = Collections.singletonList(place); List<Place> actual = parser.readPredictionsArray(reader); assertEquals(expected, actual); } }
seatgeek/android-PlacesAutocompleteTextView
placesautocomplete/src/test/java/com/seatgeek/placesautocomplete/json/AndroidPlacesApiJsonParserTest.java
Java
bsd-2-clause
18,801
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Web.Mvc; using System.Xml; using BLToolkit.EditableObjects; using bv.model.BLToolkit; using bv.model.Model.Core; using eidss.model.Core; using eidss.model.Enums; using eidss.model.Reports; using eidss.model.Reports.Common; using eidss.model.Schema; using eidss.web.common.Controllers; using eidss.web.common.Utils; using eidss.webclient.Utils; namespace eidss.webclient.Controllers { [AuthorizeEIDSS] public class AggregateSummaryController : BvController { //[HttpPost] bug 12240 public ActionResult AddSelectedAggregateCaseItems(string selectedItems, string reportAreaType, string reportPeriodType, long idfAggrCase) { var selectedIds = selectedItems.Split(',').Select(c => Int64.Parse(c)).ToList(); var selection = GetSelectedItems(selectedIds, idfAggrCase); var data = new CompareModel(); string strMessage; bool res = ValidateSelectedItems(selection.ToList(), reportAreaType, reportPeriodType, idfAggrCase, out strMessage); if (res) { //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); ObjectStorage.Using<IObject, bool>(aggrSum => { if (aggrSum is HumanAggregateCaseSummary) (aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems.AddRange(selection.Where(c => !(aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems.Any(i => i.idfAggrCase == (long)c.Key && !i.IsMarkedToDelete)).ToList()); else if (aggrSum is VetAggregateCaseSummary) (aggrSum as VetAggregateCaseSummary).AggregateCaseListItems.AddRange(selection.Where(c => !(aggrSum as VetAggregateCaseSummary).AggregateCaseListItems.Any(i => i.idfAggrCase == (long)c.Key && !i.IsMarkedToDelete)).ToList()); else if (aggrSum is VetAggregateActionSummary) (aggrSum as VetAggregateActionSummary).AggregateCaseListItems.AddRange(selection.Where(c => !(aggrSum as VetAggregateActionSummary).AggregateCaseListItems.Any(i => i.idfAggrCase == (long)c.Key && !i.IsMarkedToDelete)).ToList()); return false; }, ModelUserContext.ClientID, idfAggrCase, null); } else { data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", strMessage, false, false, false); } return new JsonResult { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } [HttpPost] public ActionResult RemoveAllAggregateCaseItems(long idfAggrCase) { //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, ActionResult>(aggrSum => { if (aggrSum is HumanAggregateCaseSummary) (aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems.RemoveAll(c => true); else if (aggrSum is VetAggregateCaseSummary) (aggrSum as VetAggregateCaseSummary).AggregateCaseListItems.RemoveAll(c => true); else if (aggrSum is VetAggregateActionSummary) (aggrSum as VetAggregateActionSummary).AggregateCaseListItems.RemoveAll(c => true); var data = new CompareModel(); return new JsonResult { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }, ModelUserContext.ClientID, idfAggrCase, null); } private bool ValidateSelectedItems(IList<IObject> selection, string reportAreaType, string reportPeriodType, long idfAggrCase, out string errorMessage) { Dictionary<string, object> parameters = GetValidationParameters(reportAreaType, reportPeriodType, idfAggrCase); bool isItemsValid = AggregateHelper.ValidateSelection(selection, parameters, out errorMessage); return isItemsValid; } private Dictionary<string, object> GetValidationParameters(string reportAreaType, string reportPeriodType, long idfAggrCase) { var parameters = new Dictionary<string, object>(); IObject firstRow = GetGridFirstRow(idfAggrCase); if (firstRow != null) { Int64 areaType = Int64.Parse(firstRow.GetValue("idfsAreaType").ToString()); Int64 periodType = Int64.Parse(firstRow.GetValue("idfsPeriodType").ToString()); parameters.Add("AreaType", areaType); parameters.Add("PeriodType", periodType); } parameters.Add("ReportAreaType", Int64.Parse(reportAreaType)); parameters.Add("ReportPeriodType", Int64.Parse(reportPeriodType)); return parameters; } private IObject GetGridFirstRow(long idfAggrCase) { //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, IObject>(aggrSum => { if (aggrSum is HumanAggregateCaseSummary && (aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems.Count > 0) return (aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems[0]; if (aggrSum is VetAggregateCaseSummary && (aggrSum as VetAggregateCaseSummary).AggregateCaseListItems.Count > 0) return (aggrSum as VetAggregateCaseSummary).AggregateCaseListItems[0]; if (aggrSum is VetAggregateActionSummary && (aggrSum as VetAggregateActionSummary).AggregateCaseListItems.Count > 0) return (aggrSum as VetAggregateActionSummary).AggregateCaseListItems[0]; return null; }, ModelUserContext.ClientID, idfAggrCase, null); } private IList<IObject> GetSelectedItems(List<long> selectedIds, long idfAggrCase) { //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, IList<IObject>>(aggrSum => { using (var manager = DbManagerFactory.Factory.Create(model.Core.EidssUserContext.Instance)) { if (aggrSum is HumanAggregateCaseSummary) return HumanAggregateCaseListItem.Accessor.Instance(null).SelectListT(manager).Where(x => selectedIds.Contains(x.idfAggrCase)).Cast<IObject>().ToList(); if (aggrSum is VetAggregateCaseSummary) return VetAggregateCaseListItem.Accessor.Instance(null).SelectListT(manager).Where(x => selectedIds.Contains(x.idfAggrCase)).Cast<IObject>().ToList(); if (aggrSum is VetAggregateActionSummary) return VetAggregateActionListItem.Accessor.Instance(null).SelectListT(manager).Where(x => selectedIds.Contains(x.idfAggrCase)).Cast<IObject>().ToList(); } return new List<IObject>(); }, ModelUserContext.ClientID, idfAggrCase, null); } [HttpGet] [CompressFilter] public ActionResult SummaryFlexibleForm(long idfAggrCase) { var ffData = GetFlexibleFormDataForJsonResult(idfAggrCase); return Json(new { data = ffData }, JsonRequestBehavior.AllowGet); } #region Get Flexible Form data for JsonResult private object GetFlexibleFormDataForJsonResult(long idfAggrCase) { //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, object>(aggrSum => { var ffData = new object(); if (aggrSum is HumanAggregateCaseSummary) ffData = GetAggregateCaseFlexibleFormData(FFTypeEnum.HumanAggregateCase, idfAggrCase); else if (aggrSum is VetAggregateCaseSummary) ffData = GetAggregateCaseFlexibleFormData(FFTypeEnum.VetAggregateCase, idfAggrCase); else if (aggrSum is VetAggregateActionSummary) ffData = GetVetAggregateActionFlexibleFormData(idfAggrCase); return ffData; }, ModelUserContext.ClientID, idfAggrCase, null); } private object GetAggregateCaseFlexibleFormData(FFTypeEnum aggregateCaseType, long idfAggrCase) { var divData = GetFlexibleFormSummaryData(aggregateCaseType, "idfCaseObservation", "divFfSummary", idfAggrCase); var resultData = new object[1] { divData }; return resultData; } private object GetVetAggregateActionFlexibleFormData(long idfAggrCase) { var divDiagnosticData = GetFlexibleFormSummaryData(FFTypeEnum.VetEpizooticActionDiagnosisInv, "idfDiagnosticObservation", "divDiagnosticFfSummary", idfAggrCase); var divProphylacticData = GetFlexibleFormSummaryData(FFTypeEnum.VetEpizooticActionTreatment, "idfProphylacticObservation", "divProphilacticFfSummary", idfAggrCase); var divSanitaryData = GetFlexibleFormSummaryData(FFTypeEnum.VetEpizooticAction, "idfSanitaryObservation", "divSanitaryFfSummary", idfAggrCase); var vetAggregateActionResultData = new object[3] { divDiagnosticData, divProphylacticData, divSanitaryData }; return vetAggregateActionResultData; } private object GetFlexibleFormSummaryData(FFTypeEnum ffType, string observationFieldName, string divName, long idfAggrCase) { var ffModel = new FFPresenterModel((long)ffType); ffModel.PrepareSummary(GetObservarionsList(observationFieldName, idfAggrCase)); ObjectStorage.Put(ModelUserContext.ClientID, idfAggrCase, idfAggrCase + 1, (idfAggrCase + 2).ToString(), ffModel); string aggregateCaseDivContent = ""; //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, object>(aggrSum => { if (aggrSum is HumanAggregateCaseSummary) aggregateCaseDivContent = this.RenderPartialView("HumanAggregateCaseFlexibleForm", aggrSum as HumanAggregateCaseSummary); else if (aggrSum is VetAggregateCaseSummary) aggregateCaseDivContent = this.RenderPartialView("VetAggregateCaseFlexibleForm", aggrSum as VetAggregateCaseSummary); else if (aggrSum is VetAggregateActionSummary) aggregateCaseDivContent = this.RenderPartialView("VetAggregateActionFlexibleForm", aggrSum as VetAggregateActionSummary); var ffSummaryData = new { divId = divName, divContent = aggregateCaseDivContent }; return ffSummaryData; }, ModelUserContext.ClientID, idfAggrCase, null); } private List<long> GetObservarionsList(string observationFieldName, long idfAggrCase) { //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, List<long>>(aggrSum => { var observations = new List<long>(); if (aggrSum is HumanAggregateCaseSummary && (aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems.Count > 0) observations = (aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems.Where(i => !i.IsMarkedToDelete).Select(item => (long)item.GetValue(observationFieldName)).ToList(); if (aggrSum is VetAggregateCaseSummary && (aggrSum as VetAggregateCaseSummary).AggregateCaseListItems.Count > 0) observations = (aggrSum as VetAggregateCaseSummary).AggregateCaseListItems.Where(i => !i.IsMarkedToDelete).Select(item => (long)item.GetValue(observationFieldName)).ToList(); if (aggrSum is VetAggregateActionSummary && (aggrSum as VetAggregateActionSummary).AggregateCaseListItems.Count > 0) observations = (aggrSum as VetAggregateActionSummary).AggregateCaseListItems.Where(i => !i.IsMarkedToDelete).Select(item => (long)item.GetValue(observationFieldName)).ToList(); return observations; }, ModelUserContext.ClientID, idfAggrCase, null); } #endregion [HttpGet] public ActionResult AggregateReport(string reportAreaType, string reportPeriodType, long idfAggrCase) { byte[] report = GetPdfReport(reportAreaType, reportPeriodType, idfAggrCase); return ReportResponse(report, "AggregateReport.pdf"); } private static StatisticAreaType ConvertStringToStatisticAreaType(string value) { StatisticAreaType result = (bv.common.Core.Utils.IsEmpty(value)) ? StatisticAreaType.None : (StatisticAreaType)Int64.Parse(value); return result; } private static StatisticPeriodType ConvertStringToStatisticPeriodType(string value) { StatisticPeriodType result = (bv.common.Core.Utils.IsEmpty(value)) ? StatisticPeriodType.None : (StatisticPeriodType)Int64.Parse(value); return result; } private int GetGridRowsCount(long idfAggrCase) { //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, int>(aggrSum => { if (aggrSum is HumanAggregateCaseSummary) return (aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems.Count(c => !c.IsMarkedToDelete); if (aggrSum is VetAggregateCaseSummary) return (aggrSum as VetAggregateCaseSummary).AggregateCaseListItems.Count(c => !c.IsMarkedToDelete); if (aggrSum is VetAggregateActionSummary) return (aggrSum as VetAggregateActionSummary).AggregateCaseListItems.Count(c => !c.IsMarkedToDelete); return 0; }, ModelUserContext.ClientID, idfAggrCase, null); } private List<IObject> GetGridRows(long idfAggrCase) { //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, List<IObject>>(aggrSum => { if (aggrSum is HumanAggregateCaseSummary) return (aggrSum as HumanAggregateCaseSummary).AggregateCaseListItems.Where(c => !c.IsMarkedToDelete).Cast<IObject>().ToList(); if (aggrSum is VetAggregateCaseSummary) return (aggrSum as VetAggregateCaseSummary).AggregateCaseListItems.Where(c => !c.IsMarkedToDelete).Cast<IObject>().ToList(); if (aggrSum is VetAggregateActionSummary) return (aggrSum as VetAggregateActionSummary).AggregateCaseListItems.Where(c => !c.IsMarkedToDelete).Cast<IObject>().ToList(); return new List<IObject>(); }, ModelUserContext.ClientID, idfAggrCase, null); } private static XmlDocument InitXml(string areaType, string periodType, ref XmlNode adminNode, ref XmlNode timeIntervalNode) { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml("<?xml version=\"1.0\" encoding =\"UTF-16\"?><ROOT/>"); XmlNode root = xmlDocument.DocumentElement; adminNode = xmlDocument.CreateNode(XmlNodeType.Element, "AdminLevel", root.NamespaceURI); XmlAttribute attrAreaType = xmlDocument.CreateAttribute("AreaType"); attrAreaType.Value = bv.common.Core.Utils.Str(areaType); adminNode.Attributes.Append(attrAreaType); root.AppendChild(adminNode); timeIntervalNode = xmlDocument.CreateNode(XmlNodeType.Element, "TimeInterval", root.NamespaceURI); XmlAttribute attrPeriodType = xmlDocument.CreateAttribute("PeriodType"); attrPeriodType.Value = bv.common.Core.Utils.Str(periodType); timeIntervalNode.Attributes.Append(attrPeriodType); root.AppendChild(timeIntervalNode); return xmlDocument; } private static void AddAdminUnitNode(XmlDocument xmlDocument, XmlNode adminNode, string adminUnitID) { XmlNode adminUnitNode = xmlDocument.CreateNode(XmlNodeType.Element, "AdminUnit", adminNode.NamespaceURI); XmlAttribute attrAUID = xmlDocument.CreateAttribute("AdminUnitID"); attrAUID.Value = bv.common.Core.Utils.Str(adminUnitID); adminUnitNode.Attributes.Append(attrAUID); adminNode.AppendChild(adminUnitNode); } private static void AddTimeIntervalUnitNode(XmlDocument xmlDocument, XmlNode timeIntervalNode, DateTime startDate, DateTime finishDate) { XmlNode timeIntervalUnitNode = xmlDocument.CreateNode(XmlNodeType.Element, "TimeIntervalUnit", timeIntervalNode.NamespaceURI); XmlAttribute attrSD = xmlDocument.CreateAttribute("StartDate"); attrSD.Value = startDate.ToString("yyyy-MM-dd"); timeIntervalUnitNode.Attributes.Append(attrSD); XmlAttribute attrFD = xmlDocument.CreateAttribute("FinishDate"); attrFD.Value = finishDate.ToString("yyyy-MM-dd"); timeIntervalUnitNode.Attributes.Append(attrFD); timeIntervalNode.AppendChild(timeIntervalUnitNode); } private static string GetAdminUnit(IObject bo, StatisticAreaType reportAreaType) { switch (reportAreaType) { case StatisticAreaType.Country: return bv.common.Core.Utils.Str(bo.GetValue("idfsCountry") ?? 0); case StatisticAreaType.Rayon: return bv.common.Core.Utils.Str(bo.GetValue("idfsRayon") ?? 0); case StatisticAreaType.Region: return bv.common.Core.Utils.Str(bo.GetValue("idfsRegion") ?? 0); case StatisticAreaType.Settlement: return bv.common.Core.Utils.Str(bo.GetValue("idfsSettlement") ?? 0); default: return "0"; } } private string GetCurrentParametersXML(StatisticAreaType reportAreaType, StatisticPeriodType reportPeriodType, long idfAggrCase) { //int gridRowsCount = GetGridRowsCount(idfAggrCase); //if (gridRowsCount > 0) //{ XmlNode adminNode = null; XmlNode timeIntervalNode = null; XmlDocument xmlDocument = InitXml(reportAreaType.ToString(), reportPeriodType.ToString(), ref adminNode, ref timeIntervalNode); IEnumerable<IObject> areas = GetGridRows(idfAggrCase).Distinct(new AreaComparer(reportAreaType)); foreach (IObject area in areas) { AddAdminUnitNode(xmlDocument, adminNode, GetAdminUnit(area, reportAreaType)); } IEnumerable<IObject> periods = GetGridRows(idfAggrCase).Distinct(new PeriodComparer()); foreach (IObject period in periods) { AddTimeIntervalUnitNode(xmlDocument, timeIntervalNode, Convert.ToDateTime(period.GetValue("datStartDate")), Convert.ToDateTime(period.GetValue("datFinishDate"))); } var sb = new StringBuilder(); var sw = new StringWriter(sb); var xmlW = new XmlTextWriter(sw); xmlDocument.WriteTo(xmlW); xmlW.Close(); sw.Close(); string aggrXml = sb.ToString(); return aggrXml; //} //return null; } private byte[] GetPdfReport(string reportAreaType, string reportPeriodType, long idfAggrCase) { StatisticAreaType areaType = ConvertStringToStatisticAreaType(reportAreaType); StatisticPeriodType periodType = ConvertStringToStatisticPeriodType(reportPeriodType); string parametersXml = GetCurrentParametersXML(areaType, periodType, idfAggrCase); //var aggrSum = ModelStorage.Get(ModelUserContext.ClientID, idfAggrCase, null); return ObjectStorage.Using<IObject, byte[]>(aggrSum => { byte[] report = null; if (aggrSum is HumanAggregateCaseSummary) { List<long> humanObservations = GetObservarionsList("idfCaseObservation", idfAggrCase); if (humanObservations.Count > 0) { using (var wrapper = new ReportClientWrapper()) { var model = new AggregateSummaryModel(ModelUserContext.CurrentLanguage, parametersXml, humanObservations, ModelUserContext.Instance.IsArchiveMode); report = wrapper.Client.ExportHumAggregateCaseSummary(model); } } } else if (aggrSum is VetAggregateCaseSummary) { List<long> observations = GetObservarionsList("idfCaseObservation", idfAggrCase); if (observations.Count > 0) { using (var wrapper = new ReportClientWrapper()) { var model = new AggregateSummaryModel(ModelUserContext.CurrentLanguage, parametersXml, observations, ModelUserContext.Instance.IsArchiveMode); report = wrapper.Client.ExportVetAggregateCaseSummary(model); } } } else if (aggrSum is VetAggregateActionSummary) { report = GetVetAggregateActionReport(ModelUserContext.CurrentLanguage, parametersXml, idfAggrCase); } return report; }, ModelUserContext.ClientID, idfAggrCase, null); } private byte[] GetVetAggregateActionReport(string language, string parametersXml, long idfAggrCase) { List<long> diagnosticObservations = GetObservarionsList("idfDiagnosticObservation", idfAggrCase); List<long> prophylacticObservations = GetObservarionsList("idfProphylacticObservation", idfAggrCase); List<long> sanitaryObservations = GetObservarionsList("idfSanitaryObservation", idfAggrCase); Dictionary<string, string> labels = GetLabelsForVetAggregateActionTab(language); byte[] report = null; if (diagnosticObservations.Count > 0 && prophylacticObservations.Count > 0 && sanitaryObservations.Count > 0) { using (var wrapper = new ReportClientWrapper()) { var aggrParams = new AggregateActionsSummaryModel(ModelUserContext.CurrentLanguage, parametersXml, diagnosticObservations, prophylacticObservations, sanitaryObservations, labels, ModelUserContext.Instance.IsArchiveMode); report = wrapper.Client.ExportVetAggregateCaseActionsSummary(aggrParams); } } return report; } private static Dictionary<string, string> GetLabelsForVetAggregateActionTab(string language) { var labels = new Dictionary<string, string> { {"@diagnosticText" + language, Translator.GetMessageString("titleDiagnosticInvestigation")}, {"@prophylacticText" + language, Translator.GetMessageString("tabTitleTreatmentProphylacticMeasures")}, {"@sanitaryText" + language, Translator.GetMessageString("tabTitleVeterinarySanitaryMeasures")} }; return labels; } } }
EIDSS/EIDSS-Legacy
EIDSS v6.1/eidss.webclient/Controllers/AggregateSummaryController.cs
C#
bsd-2-clause
25,224
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled May 11 2021 09:30:43). // // Copyright (C) 1997-2019 Steve Nygard. // #import <XCTest/NSObject-Protocol.h> #import <XCTest/XCTElementSnapshotAttributeDataSource-Protocol.h> #import <XCTest/XCUIAXNotificationHandling-Protocol.h> @class NSArray, NSDictionary, NSString, XCAccessibilityElement, XCElementSnapshot, XCTestExpectation, XCUIAccessibilityAction, XCUIApplicationProcess, XCUIElementSnapshotRequestResult; @protocol XCUIAccessibilityInterface <NSObject, XCUIAXNotificationHandling, XCTElementSnapshotAttributeDataSource> @property(readonly, nonatomic) XCAccessibilityElement *systemApplication; @property(readonly) _Bool supportsAnimationsInactiveNotifications; @property double AXTimeout; - (XCAccessibilityElement *)accessibilityElementForElementAtPoint:(struct CGPoint)arg1 error:(id *)arg2; - (void)performWhenMenuOpens:(XCAccessibilityElement *)arg1 block:(void (^)(void))arg2; - (void)removeObserver:(id)arg1 forAXNotification:(NSString *)arg2; - (id)addObserverForAXNotification:(NSString *)arg1 handler:(void (^)(XCAccessibilityElement *, NSDictionary *))arg2; - (void)unregisterForAXNotificationsForApplicationWithPID:(int)arg1; - (void)registerForAXNotificationsForApplicationWithPID:(int)arg1 timeout:(double)arg2 completion:(void (^)(_Bool, NSError *))arg3; - (NSArray *)localizableStringsDataForActiveApplications; - (_Bool)enableFauxCollectionViewCells:(id *)arg1; - (void)notifyWhenViewControllerViewDidDisappearReply:(void (^)(NSDictionary *, NSError *))arg1; - (XCTestExpectation *)viewDidAppearExpectationForElement:(XCAccessibilityElement *)arg1 viewControllerName:(NSString *)arg2; - (void)notifyWhenNoAnimationsAreActiveForApplication:(XCUIApplicationProcess *)arg1 reply:(void (^)(NSDictionary *, NSError *))arg2; - (void)notifyOnNextOccurrenceOfUserTestingEvent:(NSString *)arg1 handler:(void (^)(NSDictionary *, NSError *))arg2; - (_Bool)cachedAccessibilityLoadedValueForPID:(int)arg1; - (id)parameterizedAttribute:(NSString *)arg1 forElement:(XCAccessibilityElement *)arg2 parameter:(id)arg3 error:(id *)arg4; - (_Bool)setAttribute:(NSString *)arg1 value:(id)arg2 element:(XCAccessibilityElement *)arg3 outError:(id *)arg4; - (XCUIElementSnapshotRequestResult *)requestSnapshotForElement:(XCAccessibilityElement *)arg1 attributes:(NSArray *)arg2 parameters:(NSDictionary *)arg3 error:(id *)arg4; - (void)notifyWhenEventLoopIsIdleForApplication:(XCUIApplicationProcess *)arg1 reply:(void (^)(NSDictionary *, NSError *))arg2; - (_Bool)performAction:(XCUIAccessibilityAction *)arg1 onElement:(XCAccessibilityElement *)arg2 value:(id)arg3 error:(id *)arg4; - (XCAccessibilityElement *)hitTestElement:(XCElementSnapshot *)arg1 withPoint:(struct CGPoint)arg2 error:(id *)arg3; - (NSArray *)interruptingUIElementsAffectingSnapshot:(XCElementSnapshot *)arg1 checkForHandledElement:(XCAccessibilityElement *)arg2 containsHandledElement:(_Bool *)arg3; - (_Bool)loadAccessibility:(id *)arg1; @end
linkedin/bluepill
bp/src/PrivateHeaders/XCTest/XCUIAccessibilityInterface-Protocol.h
C
bsd-2-clause
2,994
ecalc ===== C言語で記述した単純な電卓です. C言語の練習用に記述したもので,実装方法やアルゴリズムは非常に未熟だと思います. もし何かの参考になれば幸いです. ## 特徴 一般的な電卓パーサーの実装とは異なり、優先度順にスキャンし続けるという方法をとっています。 決して良い方法ではないと思うのですが、一応動いています。 32bit Linux/Windowsで動作するJITがついています。 ## 使い方 ヘッダをインクルードします。 JITを使用しない場合は`ecalc_jit.h`は不要です。 ```C #include "ecalc.h" #include "ecalc_jit.h" #include <stdio.h> ``` 構造体へのポインタ、変数配列、変数ポインタ配列、答えバッファを用意します。 `ECALC_JIT_TREE`はJITを使用しないのであれば不要です。 ```C struct ECALC_TOKEN *tok; ECALC_JIT_TREE *jit; double var[ECALC_VAR_COUNT]; double *vars[ECALC_VAR_COUNT]; double ans = 0; int i; /* 変数ポインタリストに変数を登録 */ for ( i = 0; i < ECALC_VAR_COUNT; i++ ) { vars[i] = &var[i]; var[i] = 0; } ``` 入力文字列をレキシカルアナライズ、パース、実行します。 答えはansに入ります。 JITを使用しない場合はツリーに変更したあと`ans = ecalc_get_tree_value( tok, vars, ans )` を実行すれば結果が得られます。 ```C /* 分割 */ tok = ecalc_make_token( "5*2+3-(42*sin(pi/4))" ); /* ツリーに変更 */ tok = ecalc_make_tree( tok ); /* 変更結果を調べる */ if ( tok != NULL ) { // JITコンパイル jit = ecalc_create_jit_tree( tok ); // JIT実行 ans = ecalc_get_jit_tree_value( jit, vars, ans ); // JIT破棄 ecalc_free_jit_tree( jit ); // JITを使わない場合はこの行だけで良い // ans = ecalc_get_tree_value( tok, vars, ans ); printf( "%f\n", ans ); } else { puts( "FAILED!" ); } /* 解放 */ ecalc_free_token( tok ); ``` ## 演算子優先度 ``` 1 | () | カッコ | -> 2 | 関数 | 関数 | -> 3 | +,- | 単項-.+ | -> 4 | *,/,% | 乗除算 | -> 5 | +,- | 加減算 | -> 6 | <,> | 比較 | -> 7 | == | 同じ | -> 8 | @ | ループ | <- 9 | = | 代入 | <- 10 | , | 区切り | -> ``` ## 関数 関数には1引数関数、2引数関数、定数関数があります。 三角関数はラジアンです。 * sin(a), cos(a), tan(a), asin(a), acos(a), atan(a) * log(a) : log10 * ln(a) : 自然対数のlog * rad(a), deg(a) : aをラジアン、度に変換 * sqrt(a) : ルート * (a)pow(b) : aのb乗 * (y)atan2(x) : atan2( y, x ) * PI, EPS0 ## 文法 非常に扱いづらいですが文法要素が少しあります。 * 変数はaからzまで * a*bはabと書ける * a=3でaに3を代入 ### if文 `a`が`0`以外の時に`b=2`が実行され、式の値は`a`になります。 ``` (a)if(b=2) ``` 条件式を入れることもできます ``` (a>2)if(b=3) ``` ### ループ文 `a`回`b=b+1`を実行します。 式の値は最後に実行された`b=b+1`です。 ``` (a)@(b=b+1) ``` # License This project is licensed under the 2-clause BSD license.
futr/ecalc
README.md
Markdown
bsd-2-clause
3,195
(function(w) { "use strict"; w.matchMedia = w.matchMedia || function(doc, undefined) { var bool, docElem = doc.documentElement, refNode = docElem.firstElementChild || docElem.firstChild, fakeBody = doc.createElement("body"), div = doc.createElement("div"); div.id = "mq-test-1"; div.style.cssText = "position:absolute;top:-100em"; fakeBody.style.background = "none"; fakeBody.appendChild(div); return function(q) { div.innerHTML = '&shy;<style media="' + q + '"> #mq-test-1 { width: 42px; }</style>'; docElem.insertBefore(fakeBody, refNode); bool = div.offsetWidth === 42; docElem.removeChild(fakeBody); return { matches: bool, media: q }; }; }(w.document); })(this); (function(w) { "use strict"; var respond = {}; w.respond = respond; respond.update = function() {}; var requestQueue = [], xmlHttp = function() { var xmlhttpmethod = false; try { xmlhttpmethod = new w.XMLHttpRequest(); } catch (e) { xmlhttpmethod = new w.ActiveXObject("Microsoft.XMLHTTP"); } return function() { return xmlhttpmethod; }; }(), ajax = function(url, callback) { var req = xmlHttp(); if (!req) { return; } req.open("GET", url, true); req.onreadystatechange = function() { if (req.readyState !== 4 || req.status !== 200 && req.status !== 304) { return; } callback(req.responseText); }; if (req.readyState === 4) { return; } req.send(null); }; respond.ajax = ajax; respond.queue = requestQueue; respond.regex = { media: /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi, keyframes: /@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi, urls: /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, findStyles: /@media *([^\{]+)\{([\S\s]+?)$/, only: /(only\s+)?([a-zA-Z]+)\s?/, minw: /\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/, maxw: /\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ }; respond.mediaQueriesSupported = w.matchMedia && w.matchMedia("only all") !== null && w.matchMedia("only all").matches; if (respond.mediaQueriesSupported) { return; } var doc = w.document, docElem = doc.documentElement, mediastyles = [], rules = [], appendedEls = [], parsedSheets = {}, resizeThrottle = 30, head = doc.getElementsByTagName("head")[0] || docElem, base = doc.getElementsByTagName("base")[0], links = head.getElementsByTagName("link"), lastCall, resizeDefer, eminpx, getEmValue = function() { var ret, div = doc.createElement("div"), body = doc.body, originalHTMLFontSize = docElem.style.fontSize, originalBodyFontSize = body && body.style.fontSize, fakeUsed = false; div.style.cssText = "position:absolute;font-size:1em;width:1em"; if (!body) { body = fakeUsed = doc.createElement("body"); body.style.background = "none"; } docElem.style.fontSize = "100%"; body.style.fontSize = "100%"; body.appendChild(div); if (fakeUsed) { docElem.insertBefore(body, docElem.firstChild); } ret = div.offsetWidth; if (fakeUsed) { docElem.removeChild(body); } else { body.removeChild(div); } docElem.style.fontSize = originalHTMLFontSize; if (originalBodyFontSize) { body.style.fontSize = originalBodyFontSize; } ret = eminpx = parseFloat(ret); return ret; }, applyMedia = function(fromResize) { var name = "clientWidth", docElemProp = docElem[name], currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[name] || docElemProp, styleBlocks = {}, lastLink = links[links.length - 1], now = new Date().getTime(); if (fromResize && lastCall && now - lastCall < resizeThrottle) { w.clearTimeout(resizeDefer); resizeDefer = w.setTimeout(applyMedia, resizeThrottle); return; } else { lastCall = now; } for (var i in mediastyles) { if (mediastyles.hasOwnProperty(i)) { var thisstyle = mediastyles[i], min = thisstyle.minw, max = thisstyle.maxw, minnull = min === null, maxnull = max === null, em = "em"; if (!!min) { min = parseFloat(min) * (min.indexOf(em) > -1 ? eminpx || getEmValue() : 1); } if (!!max) { max = parseFloat(max) * (max.indexOf(em) > -1 ? eminpx || getEmValue() : 1); } if (!thisstyle.hasquery || (!minnull || !maxnull) && (minnull || currWidth >= min) && (maxnull || currWidth <= max)) { if (!styleBlocks[thisstyle.media]) { styleBlocks[thisstyle.media] = []; } styleBlocks[thisstyle.media].push(rules[thisstyle.rules]); } } } for (var j in appendedEls) { if (appendedEls.hasOwnProperty(j)) { if (appendedEls[j] && appendedEls[j].parentNode === head) { head.removeChild(appendedEls[j]); } } } appendedEls.length = 0; for (var k in styleBlocks) { if (styleBlocks.hasOwnProperty(k)) { var ss = doc.createElement("style"), css = styleBlocks[k].join("\n"); ss.type = "text/css"; ss.media = k; head.insertBefore(ss, lastLink.nextSibling); if (ss.styleSheet) { ss.styleSheet.cssText = css; } else { ss.appendChild(doc.createTextNode(css)); } appendedEls.push(ss); } } }, translate = function(styles, href, media) { var qs = styles.replace(respond.regex.keyframes, "").match(respond.regex.media), ql = qs && qs.length || 0; href = href.substring(0, href.lastIndexOf("/")); var repUrls = function(css) { return css.replace(respond.regex.urls, "$1" + href + "$2$3"); }, useMedia = !ql && media; if (href.length) { href += "/"; } if (useMedia) { ql = 1; } for (var i = 0; i < ql; i++) { var fullq, thisq, eachq, eql; if (useMedia) { fullq = media; rules.push(repUrls(styles)); } else { fullq = qs[i].match(respond.regex.findStyles) && RegExp.$1; rules.push(RegExp.$2 && repUrls(RegExp.$2)); } eachq = fullq.split(","); eql = eachq.length; for (var j = 0; j < eql; j++) { thisq = eachq[j]; mediastyles.push({ media: thisq.split("(")[0].match(respond.regex.only) && RegExp.$2 || "all", rules: rules.length - 1, hasquery: thisq.indexOf("(") > -1, minw: thisq.match(respond.regex.minw) && parseFloat(RegExp.$1) + (RegExp.$2 || ""), maxw: thisq.match(respond.regex.maxw) && parseFloat(RegExp.$1) + (RegExp.$2 || "") }); } } applyMedia(); }, makeRequests = function() { if (requestQueue.length) { var thisRequest = requestQueue.shift(); ajax(thisRequest.href, function(styles) { translate(styles, thisRequest.href, thisRequest.media); parsedSheets[thisRequest.href] = true; w.setTimeout(function() { makeRequests(); }, 0); }); } }, ripCSS = function() { for (var i = 0; i < links.length; i++) { var sheet = links[i], href = sheet.href, media = sheet.media, isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet"; if (!!href && isCSS && !parsedSheets[href]) { if (sheet.styleSheet && sheet.styleSheet.rawCssText) { translate(sheet.styleSheet.rawCssText, href, media); parsedSheets[href] = true; } else { if (!/^([a-zA-Z:]*\/\/)/.test(href) && !base || href.replace(RegExp.$1, "").split("/")[0] === w.location.host) { if (href.substring(0, 2) === "//") { href = w.location.protocol + href; } requestQueue.push({ href: href, media: media }); } } } } makeRequests(); }; ripCSS(); respond.update = ripCSS; respond.getEmValue = getEmValue; function callMedia() { applyMedia(true); } if (w.addEventListener) { w.addEventListener("resize", callMedia, false); } else if (w.attachEvent) { w.attachEvent("onresize", callMedia); } })(this);
fergalmoran/dss
static/js/lib/ace/uncompressed/respond.src.js
JavaScript
bsd-2-clause
8,153
/* Copyright (c) 2006, Tim Becker All rights reserved. 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. 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 OWNER 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. */ function dumpProperties (obj) { var result = "" print(obj) for (var p in obj){ print(""+p+" = "+obj[p]+"") } // print ("<dl>") // for (var p in obj){ // print("<dt>"+p+"</dt><dd><pre>"+obj[p]+"</pre></dd>") // } // print ("<dl>") } function print (obj) { document.writeln(obj+"<br>") } function write (obj) { document.writeln(obj); } function toggle(elId) { var e = document.getElementById(elId); if (e.style.display == "block") e.style.display = "none"; else e.style.display = "block"; return false; } function debugInfo () { print ("Browser Infos (<a href=\"#\" onclick=\"toggle(\'debugInfo\')\">+</a>)") print("<small><div id=\"debugInfo\" style=\"display:none\" class=\"source\">") dumpProperties (navigator) print("") print("</div></small>") } function escapeHTML (str) { str= str.replace(/</g, "&lt;") str= str.replace(/>/g, "&gt;") str= str.replace(/&/g, "&amp;") return str } function runTests (testArr) { write ("<h1>"+document.title+"</h1>") var numFailed = 0 var numException = 0 for (var i=0; i!=testArr.length; ++i) { var result try { result = testArr[i]() if (!result) ++numFailed }catch (e) { print("<hr><h3>Exception executing: "+i+"</h3>") dumpProperties (e) ++numException ++numFailed } //print("<hr>") print ("Test #"+i+" passed: "+result+"") write ("<small>Show test(<a href=\"#\" onclick=\"toggle(\'test"+i+"\')\">+</small></a>) <div id=\"test"+i+"\" style=\"display:none\" class=\"source\"><pre>") write (""+escapeHTML(testArr[i].toString())+"") print("</pre></div>") } write("<hr>") print ("numFailed ="+numFailed+" with Exception: "+numException) if (parent.frames.menu) { try { parent.frames.menu.addResult (document.title, testArr.length, numFailed, numException, this.location) } catch (e) { alert(e) } } debugInfo() }
a2800276/jsxmlRPC
src/test_basics.js
JavaScript
bsd-2-clause
3,340
<!DOCTYPE html> <!-- Copyright (c) 2013, the polymer_elements.dart project authors. Please see the AUTHORS file for details. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. This work is a port of the polymer-elements from the Polymer project, http://www.polymer-project.org/. --> <link rel="import" href="polymer_animation.html"> <polymer-element name="polymer-blink" extends="polymer-animation"> <template><content></content></template> <script type="application/dart;component=1" src="polymer_blink.dart"></script> </polymer-element>
bwu-dart-graveyard/polymer_elements
lib/polymer_animation/polymer_blink.html
HTML
bsd-2-clause
614
import unittest from nose2 import events, loader, session from nose2.plugins.loader import functions from nose2.tests._common import TestCase class TestFunctionLoader(TestCase): def setUp(self): self.session = session.Session() self.loader = loader.PluggableTestLoader(self.session) self.plugin = functions.Functions(session=self.session) def test_can_load_test_functions_from_module(self): class Mod(object): pass def test(): pass m = Mod() m.test = test event = events.LoadFromModuleEvent(self.loader, m) self.session.hooks.loadTestsFromModule(event) self.assertEqual(len(event.extraTests), 1) assert isinstance(event.extraTests[0], unittest.FunctionTestCase) def test_ignores_generator_functions(self): class Mod(object): pass def test(): yield m = Mod() m.test = test event = events.LoadFromModuleEvent(self.loader, m) self.session.hooks.loadTestsFromModule(event) self.assertEqual(len(event.extraTests), 0) def test_ignores_functions_that_take_args(self): class Mod(object): pass def test(a): pass m = Mod() m.test = test event = events.LoadFromModuleEvent(self.loader, m) self.session.hooks.loadTestsFromModule(event) self.assertEqual(len(event.extraTests), 0)
ptthiem/nose2
nose2/tests/unit/test_functions_loader.py
Python
bsd-2-clause
1,464
from .binary_search_tree import BinarySearchTree
dskoda1/hpds
hpds/trees/__init__.py
Python
bsd-2-clause
49
#include <FLIGHT/Core/AssetManager.hpp> #include <FLIGHT/Core/Game.hpp> #include <FLIGHT/Entity/Plane.hpp> #include <FLIGHT/Graphics/OpenGLDisplayImpl.hpp> #include <FLIGHT/Entity/Coin.hpp> namespace FLIGHT { void DisplayShadowOverlay(const float amount) { auto & game = Singleton<Game>::Instance(); glDisable(GL_DEPTH_TEST); auto & genericProg = game.GetAssetMgr().GetProgram<ShaderProgramId::Generic>(); genericProg.Use(); const auto windowSize = game.GetSubwindowSize(); const glm::mat4 ortho = glm::ortho(0.f, static_cast<float>(windowSize.x), 0.f, static_cast<float>(windowSize.y)); genericProg.SetUniformMat4("cameraSpace", ortho); glm::mat4 model = glm::translate(glm::mat4(1), {0, windowSize.y, 0.f}); model = glm::scale(model, {windowSize.x, windowSize.y, 0.f}); PRIMITIVES::Quad quad; genericProg.SetUniformVec4("color", {0, 0, 0, amount}); genericProg.SetUniformMat4("model", model); quad.Display(genericProg, AlphaBlend); glEnable(GL_DEPTH_TEST); } static const glm::mat4 LIGHT_PROJ_MAT = glm::ortho(-4.f, 4.f, -4.f, 4.f, -5.f, 12.f); static void UpdatePerspProjUniforms() { auto & game = Singleton<Game>::Instance(); auto & assets = game.GetAssetMgr(); auto & shadowProgram = assets.GetProgram<ShaderProgramId::Shadow>(); auto & lightingProg = assets.GetProgram<ShaderProgramId::Base>(); auto & terrainProg = assets.GetProgram<ShaderProgramId::Terrain>(); auto & genericTxtrdProg = assets.GetProgram<ShaderProgramId::GenericTextured>(); auto & skyProg = assets.GetProgram<ShaderProgramId::SkyGradient>(); auto & solidColProg = assets.GetProgram<ShaderProgramId::SolidColor3D>(); shadowProgram.Use(); auto & camera = game.GetCamera(); auto view = camera.GetLightView(); auto lightSpace = LIGHT_PROJ_MAT * view; shadowProgram.SetUniformMat4("lightSpace", lightSpace); lightingProg.Use(); view = camera.GetWorldView(); const auto & windowSize = game.GetSubwindowSize(); const float aspect = static_cast<float>(windowSize.x) / static_cast<float>(windowSize.y); const glm::mat4 perspective = glm::perspective(45.0f, aspect, 0.1f, 1.0f); auto cameraSpace = perspective * view; lightingProg.SetUniformMat4("lightSpace", lightSpace); lightingProg.SetUniformMat4("cameraSpace", cameraSpace); terrainProg.Use(); terrainProg.SetUniformMat4("cameraSpace", cameraSpace); genericTxtrdProg.Use(); genericTxtrdProg.SetUniformMat4("cameraSpace", cameraSpace); skyProg.Use(); skyProg.SetUniformMat4("cameraSpace", cameraSpace); solidColProg.Use(); solidColProg.SetUniformMat4("cameraSpace", cameraSpace); } static void DrawTerrain(OpenGLDisplayImpl & gl) { auto & game = Singleton<Game>::Instance(); auto & terrainProg = game.GetAssetMgr().GetProgram<ShaderProgramId::Terrain>(); terrainProg.Use(); const auto view = game.GetCamera().GetWorldView(); auto invView = glm::inverse(view); glm::vec3 eyePos = invView * glm::vec4(0, 0, 0, 1); terrainProg.SetUniformVec3("eyePos", eyePos); Singleton<Game>::Instance().GetTerrainMgr().Display(gl); AssertGLStatus("terrain rendering"); } static void UpdateOrthoProjUniforms() { auto & game = Singleton<Game>::Instance(); auto & assets = game.GetAssetMgr(); auto & lensFlareProg = assets.GetProgram<ShaderProgramId::LensFlare>(); lensFlareProg.Use(); const auto windowSize = game.GetSubwindowSize(); const glm::mat4 ortho = glm::ortho(0.f, static_cast<float>(windowSize.x), 0.f, static_cast<float>(windowSize.y)); lensFlareProg.SetUniformMat4("proj", ortho); auto & reticleProg = assets.GetProgram<ShaderProgramId::Reticle>(); reticleProg.Use(); reticleProg.SetUniformMat4("proj", ortho); auto & powerupProgBG = assets.GetProgram<ShaderProgramId::PowerupBG>(); powerupProgBG.Use(); powerupProgBG.SetUniformMat4("proj", ortho); auto & powerupProgFG = assets.GetProgram<ShaderProgramId::PowerupFG>(); powerupProgFG.Use(); powerupProgFG.SetUniformMat4("proj", ortho); auto & reticleShadowProg = assets.GetProgram<ShaderProgramId::ReticleShadow>(); reticleShadowProg.Use(); reticleShadowProg.SetUniformMat4("proj", ortho); auto & txtrdQuadProg = assets.GetProgram<ShaderProgramId::GenericTextured>(); txtrdQuadProg.Use(); txtrdQuadProg.SetUniformMat4("cameraSpace", ortho); auto & fontShader = assets.GetProgram<ShaderProgramId::Font>(); fontShader.Use(); fontShader.SetUniformMat4("proj", ortho); } extern std::array<SkyManager::Flare, 11> g_lensFlares; static void DoLensFlare() { auto & game = Singleton<Game>::Instance(); if (game.GetSkyMgr().SunVisible()) { auto & lensFlareProg = game.GetAssetMgr().GetProgram<ShaderProgramId::LensFlare>(); lensFlareProg.Use(); for (const auto & flare : g_lensFlares) { lensFlareProg.SetUniformFloat("intensity", 0.3f * flare.intensity); PRIMITIVES::Hexagon hex; glm::mat4 model = glm::translate(glm::mat4(1), flare.position); model = glm::scale(model, {flare.scale, flare.scale, flare.scale}); lensFlareProg.SetUniformMat4("model", model); hex.Display(lensFlareProg, AdditiveBlend); } } } inline static void DrawPowerups() { auto & game = Singleton<Game>::Instance(); auto & assets = game.GetAssetMgr(); const auto & windowSize = game.GetSubwindowSize(); auto mark = windowSize; static const float bubbleRadius = CalcPowerupIconSize(windowSize); mark.x -= bubbleRadius * 2.f; auto & powerupProgBG = assets.GetProgram<ShaderProgramId::PowerupBG>(); auto & powerupProgFG = assets.GetProgram<ShaderProgramId::PowerupFG>(); PRIMITIVES::TexturedQuad quad; for (auto powerup : game.GetPlayer1().GetPowerups()) { if (powerup == Powerup::None) { continue; } powerupProgBG.Use(); mark.y -= bubbleRadius * 2.5f; const float p1Score = game.GetPlayer1().GetDelayedScore(); const Score cost = GetCost(powerup); glm::mat4 model = glm::translate(glm::mat4(1), {mark.x, mark.y, 0.f}); model = glm::scale(model, {bubbleRadius, bubbleRadius, 0.f}); powerupProgBG.SetUniformMat4("model", model); quad.Display(powerupProgBG, AlphaBlend); powerupProgFG.Use(); const float fillRatio = std::min(1.f, p1Score / cost); powerupProgFG.SetUniformFloat("fill", fillRatio); powerupProgFG.SetUniformMat4("model", model); glActiveTexture(GL_TEXTURE0); powerupProgFG.SetUniformInt("tex", 0); std::shared_ptr<Texture> icon; switch (powerup) { case Powerup::Dash: icon = assets.GetPowerupIcon<Powerup::Dash>(); break; case Powerup::Pulse: icon = assets.GetPowerupIcon<Powerup::Pulse>(); break; case Powerup::Heal: icon = assets.GetPowerupIcon<Powerup::Heal>(); break; } glBindTexture(GL_TEXTURE_2D, icon->GetId()); quad.Display(powerupProgFG, AlphaBlend); glBindTexture(GL_TEXTURE_2D, 0); } } static void DrawOverlays() { UpdateOrthoProjUniforms(); glDisable(GL_DEPTH_TEST); Singleton<Game>::Instance().GetCamera().DisplayOverlay(); DoLensFlare(); DrawPowerups(); glEnable(GL_DEPTH_TEST); } constexpr static size_t GetChunkIndexCount(const size_t scale) { return ((((CHUNK_SIZE + TerrainChunk::GetMargin()) / scale) - 1) * (((CHUNK_SIZE + TerrainChunk::GetMargin()) / scale) - 1)) * 6; } void OpenGLDisplayImpl::InitChunkIndexBufs() { constexpr const size_t chunkSize = CHUNK_SIZE + TerrainChunk::GetMargin(); MeshBuilder meshBuilderHQ(chunkSize, chunkSize); MeshBuilder meshBuilderMQ(chunkSize, chunkSize); MeshBuilder meshBuilderLQ(chunkSize, chunkSize); MeshBuilder meshBuilderDQ(chunkSize, chunkSize); int vertIndex = 0; for (size_t y = 0; y < chunkSize; ++y) { for (size_t x = 0; x < chunkSize; ++x) { if (x < chunkSize - 1 and y < chunkSize - 1) { meshBuilderHQ.AddTriangle(vertIndex, vertIndex + chunkSize + 1, vertIndex + chunkSize); meshBuilderHQ.AddTriangle(vertIndex + chunkSize + 1, vertIndex, vertIndex + 1); if (x % 2 == 0 and y % 2 == 0 and x < chunkSize - 2 and y < chunkSize - 2) { meshBuilderMQ.AddTriangle(vertIndex, vertIndex + chunkSize * 2 + 2, vertIndex + chunkSize * 2); meshBuilderMQ.AddTriangle(vertIndex + chunkSize * 2 + 2, vertIndex, vertIndex + 2); } if (x % 3 == 0 and y % 3 == 0 and x < chunkSize - 3 and y < chunkSize - 3) { meshBuilderLQ.AddTriangle(vertIndex, vertIndex + chunkSize * 3 + 3, vertIndex + chunkSize * 3); meshBuilderLQ.AddTriangle(vertIndex + chunkSize * 3 + 3, vertIndex, vertIndex + 3); } if (x % 4 == 0 and y % 4 == 0 and x < chunkSize - 4 and y < chunkSize - 4) { meshBuilderDQ.AddTriangle(vertIndex, vertIndex + chunkSize * 4 + 4, vertIndex + chunkSize * 4); meshBuilderDQ.AddTriangle(vertIndex + chunkSize * 4 + 4, vertIndex, vertIndex + 4); } } ++vertIndex; } } auto meshHQ = meshBuilderHQ.GetMesh(); auto meshMQ = meshBuilderMQ.GetMesh(); auto meshLQ = meshBuilderLQ.GetMesh(); auto meshDQ = meshBuilderDQ.GetMesh(); glGenBuffers(1, &m_chunkInfo.chunkIndicesHQ); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_chunkInfo.chunkIndicesHQ); glBufferData(GL_ELEMENT_ARRAY_BUFFER, GetChunkIndexCount(1) * sizeof(GLushort), meshHQ.triangles.data(), GL_STATIC_DRAW); glGenBuffers(1, &m_chunkInfo.chunkIndicesMQ); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_chunkInfo.chunkIndicesMQ); glBufferData(GL_ELEMENT_ARRAY_BUFFER, GetChunkIndexCount(2) * sizeof(GLushort), meshMQ.triangles.data(), GL_STATIC_DRAW); glGenBuffers(1, &m_chunkInfo.chunkIndicesLQ); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_chunkInfo.chunkIndicesLQ); glBufferData(GL_ELEMENT_ARRAY_BUFFER, GetChunkIndexCount(3) * sizeof(GLushort), meshLQ.triangles.data(), GL_STATIC_DRAW); glGenBuffers(1, &m_chunkInfo.chunkIndicesDQ); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_chunkInfo.chunkIndicesDQ); glBufferData(GL_ELEMENT_ARRAY_BUFFER, GetChunkIndexCount(4) * sizeof(GLushort), meshDQ.triangles.data(), GL_STATIC_DRAW); } void OpenGLDisplayImpl::DrawShadowMap() { auto & game = Singleton<Game>::Instance(); auto & shadowProgram = game.GetAssetMgr().GetProgram<ShaderProgramId::Shadow>(); shadowProgram.Use(); const auto & windowSize = game.GetSubwindowSize(); glViewport(0, 0, windowSize.x / 2, windowSize.y / 2); glBindFramebuffer(GL_FRAMEBUFFER, m_shadowMapFBO); glClear(GL_DEPTH_BUFFER_BIT); if (auto plane = game.GetPlayer1().GetPlane()) { plane->CastShadow(shadowProgram); } AssertGLStatus("shadow loop"); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) not_eq GL_FRAMEBUFFER_COMPLETE) { throw std::runtime_error("Incomplete framebuffer"); } glBindFramebuffer(GL_FRAMEBUFFER, 0); } void OpenGLDisplayImpl::SetupShadowMap() { auto & game = Singleton<Game>::Instance(); glGenFramebuffers(1, &m_shadowMapFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_shadowMapFBO); glGenTextures(1, &m_shadowMapTxtr); glBindTexture(GL_TEXTURE_2D, m_shadowMapTxtr); const auto & windowSize = game.GetSubwindowSize(); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, windowSize.x / 2, windowSize.y / 2, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_shadowMapTxtr, 0); glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) not_eq GL_FRAMEBUFFER_COMPLETE) { throw std::runtime_error("Unable to set up frame buffer"); } glBindTexture(GL_TEXTURE_2D, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0); } static void LoadExtensions() { #ifndef __APPLE__ glewExperimental = GL_TRUE; GLenum err = glewInit(); if (err not_eq GLEW_OK) { throw std::runtime_error( std::string((const char *)glewGetErrorString(err))); } // Note: on some platforms using glewExperimental results in a // GL_INVALID_ENUM (code 0x500) err = glGetError(); if (err not_eq GL_INVALID_ENUM and err not_eq GL_NO_ERROR) { std::stringstream ss; ss << "GL error in glew initialization, code: " << std::hex << err << std::dec; throw std::runtime_error(ss.str()); } #endif } OpenGLDisplayImpl::OpenGLDisplayImpl() { LoadExtensions(); glGenVertexArrays(1, &m_vao); glBindVertexArray(m_vao); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); InitChunkIndexBufs(); PRIMITIVES::Init(); Text::Enable(); SetupShadowMap(); } OpenGLDisplayImpl::~OpenGLDisplayImpl() { glDeleteVertexArrays(1, &m_vao); } void OpenGLDisplayImpl::Dispatch(Plane & plane) { auto & shader = Singleton<Game>::Instance() .GetAssetMgr() .GetProgram<ShaderProgramId::Base>(); shader.Use(); glm::mat4 modelMatrix; modelMatrix = glm::translate(modelMatrix, plane.GetPosition()); const auto & rot = plane.GetRotation(); modelMatrix = glm::rotate(modelMatrix, rot.y, {0, 1, 0}); modelMatrix = glm::rotate(modelMatrix, rot.z, {0, 0, 1}); modelMatrix = glm::rotate(modelMatrix, rot.x, {1, 0, 0}); for (auto & part : plane.GetParts()) { part.Display(modelMatrix, shader); } } void OpenGLDisplayImpl::Dispatch(Coin & coin) { auto & game = Singleton<Game>::Instance(); auto & shader = game.GetAssetMgr().GetProgram<ShaderProgramId::SolidColor3D>(); shader.Use(); if (auto modelSp = game.GetAssetMgr().GetModel("Box.obj")) { auto binding = modelSp->Bind(shader); glm::mat4 model; model = glm::translate(model, coin.GetPosition()); shader.SetUniformMat4("model", model); shader.SetUniformVec4("color", {0.949f, 0.765f, 0.027f, 1.f}); glDrawArrays(GL_TRIANGLES, 0, binding.numVertices); } } void OpenGLDisplayImpl::Dispatch(TerrainChunk & chunk) { auto & shader = Singleton<Game>::Instance() .GetAssetMgr() .GetProgram<ShaderProgramId::Terrain>(); shader.Use(); glm::mat4 model; model = glm::translate(model, chunk.GetPosition()); glm::mat4 invTransModel = glm::transpose(glm::inverse(model)); shader.SetUniformMat4("invTransModel", invTransModel); shader.SetUniformMat4("model", model); chunk.GetMeshData().Bind(); shader.SetVertexAttribPtr("position", 3, GL_FLOAT, sizeof(VertexPN)); shader.SetVertexAttribPtr("normal", 3, GL_FLOAT, sizeof(VertexPN), sizeof(glm::vec3)); switch (chunk.GetDrawQuality()) { case TerrainChunk::DrawQuality::High: glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_chunkInfo.chunkIndicesHQ); glDrawElements(GL_TRIANGLES, GetChunkIndexCount(1), GL_UNSIGNED_SHORT, 0); break; case TerrainChunk::DrawQuality::Medium: glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_chunkInfo.chunkIndicesMQ); glDrawElements(GL_TRIANGLES, GetChunkIndexCount(2), GL_UNSIGNED_SHORT, 0); break; case TerrainChunk::DrawQuality::Low: glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_chunkInfo.chunkIndicesLQ); glDrawElements(GL_TRIANGLES, GetChunkIndexCount(3), GL_UNSIGNED_SHORT, 0); break; case TerrainChunk::DrawQuality::Despicable: glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_chunkInfo.chunkIndicesDQ); glDrawElements(GL_TRIANGLES, GetChunkIndexCount(4), GL_UNSIGNED_SHORT, 0); break; case TerrainChunk::DrawQuality::None: break; } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); } void OpenGLDisplayImpl::Dispatch(Bullet & bullet) { // TODO... } void OpenGLDisplayImpl::Dispatch(Thruster & thruster) { // TODO... } void OpenGLDisplayImpl::Dispatch(TitleScreen & titleScreen) { // TODO... } void OpenGLDisplayImpl::Dispatch(CreditsScreen & creditsScreen) { auto & game = Singleton<Game>::Instance(); const auto & windowSize = game.GetSubwindowSize(); const glm::mat4 ortho = glm::ortho(0.f, static_cast<float>(windowSize.x), 0.f, static_cast<float>(windowSize.y)); auto & fontShader = game.GetAssetMgr().GetProgram<ShaderProgramId::Font>(); fontShader.Use(); fontShader.SetUniformMat4("proj", ortho); glViewport(0, 0, windowSize.x, windowSize.y); glClearColor(0.f, 0.f, 0.f, 1.f); glClear(GL_COLOR_BUFFER_BIT); glDisable(GL_DEPTH_TEST); creditsScreen.GetText().Display(); glEnable(GL_DEPTH_TEST); AssertGLStatus("credits screen"); } void OpenGLDisplayImpl::Dispatch(WorldLoader & worldLoader) { // ... } void OpenGLDisplayImpl::Dispatch(World & world) { auto & game = Singleton<Game>::Instance(); UpdatePerspProjUniforms(); game.GetTerrainMgr().SwapChunks(); DrawShadowMap(); const auto & windowSize = game.GetSubwindowSize(); glViewport(0, 0, windowSize.x, windowSize.y); glClearColor(0.3f, 0.72f, 1.0f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); DrawTerrain(*this); game.GetSkyMgr().Display(*this); auto & lightingProg = game.GetAssetMgr().GetProgram<ShaderProgramId::Base>(); lightingProg.Use(); const auto view = game.GetCamera().GetWorldView(); auto invView = glm::inverse(view); glm::vec3 eyePos = invView * glm::vec4(0, 0, 0, 1); if (auto playerPlane = game.GetPlayer1().GetPlane()) { lightingProg.SetUniformVec3("eyePos", eyePos); lightingProg.SetUniformInt("shadowMap", 1); lightingProg.SetUniformFloat( "overrideColorAmount", game.GetPlayer1().GetPlane()->GetMixAmount()); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, m_shadowMapTxtr); playerPlane->Display(*this); } DrawOverlays(); } void OpenGLDisplayImpl::Dispatch(WorldTransitionIn & wtin) { const float overlayDarkness = 1.f - glm::smoothstep(0.f, static_cast<float>(wtin.TRANSITION_TIME), static_cast<float>(wtin.GetTimer())); DisplayShadowOverlay(overlayDarkness); } void OpenGLDisplayImpl::Dispatch(SkyManager & sky) { auto & game = Singleton<Game>::Instance(); auto & skyProg = game.GetAssetMgr().GetProgram<ShaderProgramId::SkyGradient>(); skyProg.Use(); const auto & skydomeLocus = game.GetSkyMgr().GetSkydomeCenter(); const auto & skydomeRot = game.GetSkyMgr().GetSkydomeRot(); glm::mat4 skyBgModel = glm::translate(glm::mat4(1), {skydomeLocus.x, 0, skydomeLocus.z}); skyBgModel = glm::scale(skyBgModel, {400.f, 400.f, 400.f}); skyBgModel = glm::rotate(skyBgModel, skydomeRot.y, {0, 1, 0}); skyProg.SetUniformMat4("model", skyBgModel); auto binding = game.GetAssetMgr().GetModel("SkyDome.obj")->Bind(skyProg); glDrawArrays(GL_TRIANGLES, 0, binding.numVertices); if (game.GetSkyMgr().SunVisible()) { auto & textrdQuadProg = game.GetAssetMgr().GetProgram<ShaderProgramId::GenericTextured>(); textrdQuadProg.Use(); glActiveTexture(GL_TEXTURE1); textrdQuadProg.SetUniformInt("tex", 1); glBindTexture(GL_TEXTURE_2D, game.GetAssetMgr().GetTexture("Sun.png")->GetId()); glm::mat4 model; model = glm::translate(model, game.GetSkyMgr().GetSunPos()); model = glm::scale(model, {15.f, 15.f, 15.f}); model = glm::rotate(model, skydomeRot.y, {0, 1, 0}); model = glm::rotate(model, -skydomeRot.x, {1, 0, 0}); textrdQuadProg.SetUniformMat4("model", model); PRIMITIVES::TexturedQuad quad; quad.Display(textrdQuadProg, AdditiveBlend); glBindTexture(GL_TEXTURE_2D, 0); } AssertGLStatus("rendering sky"); } }
evanbowman/FLIGHT
src/Graphics/OpenGLDisplayImpl.cpp
C++
bsd-2-clause
21,567
<?php /** * Copyright 2014 Fabian Grutschus. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. 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. * * 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 OWNER 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. * * The views and conclusions contained in the software and documentation are those * of the authors and should not be interpreted as representing official policies, * either expressed or implied, of the copyright holders. * * @author Fabian Grutschus <f.grutschus@lubyte.de> * @copyright 2014 Fabian Grutschus. All rights reserved. * @license BSD-2-Clause * @link http://github.com/purr-php/purr */ namespace Purr\Event\Task; use PHPUnit_Framework_TestCase as TestCase; /** * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-06-12 at 17:09:37. */ class AfterRunLoopTest extends TestCase { /** * @var AfterRunLoop */ protected $object; /** * @var float */ protected $time; /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->time = microtime(true); $this->object = new AfterRunLoop(array(), array($this->getMock('\\Purr\\Task\\TaskInterface'))); } /** * @covers Purr\Event\Task\AfterRunLoop::__construct * @covers Purr\Event\Task\AfterRunLoop::getExecuted * @uses Purr\Event\Task\AbstractTaskLoopEvent::__construct */ public function testGetTime() { $this->assertContainsOnlyInstancesOf('\\Purr\\Task\\TaskInterface', $this->object->getExecuted()); } }
purr-php/purr
tests/src/Event/Task/AfterRunLoopTest.php
PHP
bsd-2-clause
2,790
package org.jvnet.hyperjaxb3.xml; public class XMLConstants { private XMLConstants() { } public static final String W3C_XML_SCHEMA_NS_URI = "http://www.w3.org/2001/XMLSchema"; }
highsource/hyperjaxb3
ejb/runtime/src/main/java/org/jvnet/hyperjaxb3/xml/XMLConstants.java
Java
bsd-2-clause
184